CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F1320: TX goes low when setting B-port output

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
thb2



Joined: 25 Aug 2010
Posts: 2

View user's profile Send private message

PIC18F1320: TX goes low when setting B-port output
PostPosted: Wed Aug 25, 2010 2:02 pm     Reply with quote

Hi,

I'm using the following code on a 18F1320. After reset the TX pin is high. Then the "Startup...." is send and TX toggles a few times and then goes high again for 200 ms.
Then as soon as I set or clear PIN B3 the TX pin goes down. Can you tell me why, what am I doing wrong? There is no hardware connection between TX(B1) and B3.
My compiler is version 3.150.

Thanks in advance for any help!

Thomas

Code:

#include <18F1320.h>
#device adc=8
#use delay(clock=20000000)
#fuses HS,PUT,NOWDT,NOEBTRB,NOEBTR,NOFCMEN,NOCPD,NOPROTECT,MCLR,NOWRTB,NOWRTC,NOLVP,NOWRT,NOWRTD,NOBROWNOUT,NODEBUG,NOIESO,NOSTVREN
#use rs232(baud=9600,parity=N,xmit=PIN_B1,rcv=PIN_B4,bits=8)

#bit PINB3 = 0xF81.3 //PIC18F1220, PIN_B3


void main()
{

set_tris_a(0b00000000);
set_tris_b(0b00010000); // B4: RS232-RX


//PINB3=0;
delay_ms(3000); //don't remove (bootloader)

printf("Startup........");
delay_ms(200);

while(1)
   {
   PINB3=1;
   delay_ms(10);
   PINB3=0;
   delay_ms(10);
   }
}
thb2



Joined: 25 Aug 2010
Posts: 2

View user's profile Send private message

PostPosted: Wed Aug 25, 2010 2:12 pm     Reply with quote

OK, I replaced the

#bit PINB3 = 0xF81.3 //PIC18F1220, PIN_B3
PINB3=1;

with

output_high(PIN_B3);

and it works. Output_high is translated to

BCF F93.3 (TRISB)
BSF F8A.3 (LATB)

Is it necessary to clear the TRISB? I think I have to read the datasheet to find out what PORT, LAT and TRIS mean.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group