Hi E, [ TRANSMITTER ]OK.
Could you summarise which hardware and subroutines will be in the UART PIC, lets look into the sync problems.
E
Hi E, [ TRANSMITTER ]hi,
OK, which peripheral/s is using an Interrupt.?
E
Hi E,hi,
As the GPS asynchronous message is incoming at a 1 second rate, why not use an Interrupt for the GPS.
The other peripherals, as I recall, are called by the program, ie: on demand.
E
Hi E,What rate is the REMOTE serial coming in.? Is on demand.?
IE: does the program request the REMOTE data or is it coming in at a fixed interval.?
Hi E,hi,
Problem is, if you have two incoming serial sources, using the same HW UART and the two sources are not synchronised, you will most likely get message collisions and data will be lost or corrupted.
Is there any way you can control the REMOTE, to only send data when commanded.? [I know the GPS interval is fixed]
E
Hi E,I know that, but what controls the dataswitch and how does it know when to allow in the REMOTE.????
You check PIR1.RCIF if there is a character in RCREG. Even though it is an "interrupt flag", it does not mean you have to use it for interrupts, you can simple loop and check it with a simple read. That flag is set regardless of interrupt settings. Once set, you go read RCREG.Hi S,
...
II'll keep searching searching the DATA SHEET, for the UART RECEIVE REGISTER FLAG/STATUS.
Thanks.
C.
Hi E,hi C,
With respect that is not answering the question.
What and when decides to select the GPS or REMOTE by using the DataSwitch.???
If the two input serial messages ie: GPS and REM are not synchronised for the intervals which they transmit data.
The two messages could be arriving at the same time or slightly offset at the DataSw input, so which one has priority.
eg1: assume DataSw has selected GPS and its getting msg OK, what if the REM starts sending serial data half way through the GPS, part of REM message will be lost and the trailing bytes will be unread and will raise a OERR.
Likewise if the REM is being received first and then halway thru the GPS starts.
E
Hi S,You check PIR1.RCIF if there is a character in RCREG. Even though it is an "interrupt flag", it does not mean you have to use it for interrupts, you can simple loop and check it with a simple read. That flag is set regardless of interrupt settings. Once set, you go read RCREG.
See page 116 of the datasheet. Then read section 18.2.2 (page 215) for how the Receive section of the UART works. Step 7 is important, if you had an overflow, that is where you catch it.
Hserget gives you the option of not "hanging", waiting for a character. It simply reads the register and returns the character or a zero if there is none (Oshonsoft must check the RCIF flag and return zero if not set). Hserin will block until a character arrives, you cannot unblock it.
EDIT: When you read a valid character from RCREG, you MUST read RCREG again for a second character if PIR1.RCIF is still set. That is, RCIF is set as long as there are any characters in the RCREG FIFO (2 characters). In other words, keep reading RCREG until PIR1.RCIF is = 0
Figure 18-7 in the datasheet shows typical data receive of 3 words (to show overflow). However, you see RCREG being read twice (third line down), then PIR1.RCIF being cleared after the second read (4th line down). Since there was a 3rd character after, they show the overflow error in that example.
Hi E,hi,
For explanation only, assume that GPS data = 80 bytes in length and REM is also 80 bytes.
Say that the GPS data occurs every 1 second and so does the REM data, but the REM data start arrives 20mSec after the GPS start.
With your program you will get the GPS, ID first every time and when the DataSw toggles over then the partial data of the REM will set the OERR, as the buffer will not have been read.
Also if the GPS and REM intervals are running at slightly different occurrence rates which ever is detected first will take priority and the other message will be lost.
Do you follow.?
Is there anyway that you can prevent the REM message being sent until the GPS msg has been Read.?
E