|
|
View previous topic :: View next topic |
Author |
Message |
Jerry I
Joined: 14 Sep 2003 Posts: 96 Location: Toronto, Ontario, Canada
|
Open Closing internal uart [ Solved ] Thanks |
Posted: Mon Mar 30, 2020 11:07 am |
|
|
Using PIC18F2620, Compiler V5.078
My application will be reading from a GPS data serial stream. The data stream transmits every 1 second. I don't require the data stream every second, every 5 minutes would be fine. This GPS module does not have an option to program the how often to transmit data.
What is the best way to open and close the uart port to ignore the data coming from the data stream. This will also stop data going into the circular buffer.
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, ERRORS, stream=GPS)
disable_interrupts(INT_RDA) / enable_interrupts(INT_RDA) appears to work, but is the best way.
Thanks in advance for any suggestions.
Last edited by Jerry I on Mon Mar 30, 2020 7:48 pm; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Mar 30, 2020 12:14 pm |
|
|
That is really as good as anything, but has the caveat, that when the
interrupt is re-enabled, you may well get a couple of garbage characters.
Also doing it this way the UART will be in an error state while not
receiving, with a buffer overflow.
There is a general issue with disabling the actual UART, and re-enabling,
that if you re-enable 'mid character', you will get a garbage character,
and depending on how the string is scanned this could cause problems.
Why disable?.
Why not just turn off receipt?.
Just have a single bit flag 'rx_off', and in the UART receive interrupt handler
if this is set, just don't store the character. This then implies that the
UART receipt is still running so the UART won't go into an error. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Mar 30, 2020 1:07 pm |
|
|
Assuming you have some kinds of RTC..
within the ISR, check the RTC minutes and store the GPS data if 'minutes' is 0,5,10,15,20, etc.
There's probably a slick way to compare to '5's.. but I can't think of one right now.
I know you need to have a 'flag' so that you get ONE reading and NOT 5 minutes worth......
Also, maybe take 2 readings, compare the data or at least some form of verification as a bad reading between 2 good ones is a 10 minute 'window'. |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Mon Mar 30, 2020 2:48 pm |
|
|
Your PIC doesn't have PPS, I've done a thing before where when I don't want my UART to receive, I just set the pin to null like:
Code: | pin_select("U2RX", NULL); |
|
|
|
|
|
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
|