View previous topic :: View next topic |
Author |
Message |
boulder
Joined: 15 Mar 2008 Posts: 53
|
|
Posted: Thu Sep 17, 2009 4:19 pm |
|
|
I already tried this method, it works. However, Interrupt method does not work well. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 17, 2009 4:43 pm |
|
|
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
|
|
Posted: Thu Sep 17, 2009 5:44 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 1:20 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 4:37 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 5:04 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 6:03 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 8:56 pm |
|
|
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
|
|
Posted: Fri Sep 18, 2009 9:12 pm |
|
|
I was wrong. The compiler does take care of timing after change frequency in #use delay(). Thanks. |
|
|
|