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

PIC18F14K22 UART
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Thu Sep 17, 2009 4:19 pm     Reply with quote

I already tried this method, it works. However, Interrupt method does not work well.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 17, 2009 4:43 pm     Reply with quote

Try using a standard circular buffer, such as the Ex_Sisr.c example,
instead of your #int_rda routine.
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Thu Sep 17, 2009 5:44 pm     Reply with quote

I tried Ex_Sisr.c example, and it acts the same way. However, there is a good news that it works fine with my test code and example code if I use the other baudrates instead of 115200. Could anyone explain it to me? My project requests 115200 baudrate.

Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 1:20 pm     Reply with quote

Earlier, I did a count of the number of instruction cycles needed to
process the interrupt, and compared it to the time required to receive
or transmit a byte. I found that the isr execution time was lower,
so it should work. But, I could have overlooked something.
Easy answer:

Increase your crystal frequency to 7.3728 MHz (2x your existing freq).
This may fix the problem. Change the #use delay statement and
use the HS fuse for this frequency.
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 4:37 pm     Reply with quote

I think that it's too late to change crystal. Is it okay to enable 4xPLL in #fuse?
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 5:04 pm     Reply with quote

I enabled PLL in #fuses and changed baudrate to 28800 in #use rs232 since frequency is 4 times faster, now uart interrupt is working very well with the actual 115200 baudrate.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 6:03 pm     Reply with quote

You shouldn't use incorrect rates for the baud rate. Change the #use
delay() statement so it fits the new 4x oscillator frequency. The
compiler will setup everything correctly, provided that you set the
#use delay() to match the actual speed of the oscillator. In the case
of a 3.6864 MHz crystal with a 4x PLL, the oscillator freq is 14.74564 MHz.
See below:
Quote:

#include <18F14K22.h>
#fuses XT, NOWDT, PUT, PLLEN, NOLVP
#use delay(clock=14745600)
#use rs232(baud=115200, xmit=PIN_B7, rcv=PIN_B5, ERRORS)
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 8:56 pm     Reply with quote

PCM,
Your are right about this. However, the compiler does not take care timing. If I want to delay 100ms, I have to write 'delay_ms(400)'.

Thanks!!
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Fri Sep 18, 2009 9:12 pm     Reply with quote

I was wrong. The compiler does take care of timing after change frequency in #use delay(). Thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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