Sounds pretty good to me.
A point though..
RESET_VT
inside the ASM part of the code is an ASM label.
DEFINE INTHAND RESET_VT
Tells where to go when the interrupt occurs.
Sounds pretty good to me.
A point though..
RESET_VT
inside the ASM part of the code is an ASM label.
DEFINE INTHAND RESET_VT
Tells where to go when the interrupt occurs.
Dave
Always wear safety glasses while programming.
Hi mackrackit.
My mistake, I should have said:
If the count reaches 65536ms then the Interrupt flag TMR1IF PIR.0 goes to 1 then the program jumps to:Not the DEFINE.Code:RESET_VT
So when the program jumps after PIR.0 = 1 to RESET_VT it then runs the Register saving code, then the INTERRUPT routine, then restores all the previously saved values back to exactly the same condition as pre - RESET_VT. Can we come back to that part the ASM stuff later but for now assume there was some DATA received and the next block of PBP code.
Dave
Yup, sounds like you have the interrupt idea worked out.Can we come back to that part the ASM stuff later but for now assume there was some DATA received and the next block of PBP code.
On to MAIN...
Dave
Always wear safety glasses while programming.
So the Timer1 is running and we've got 65.5ms to receive the data.MAIN:
' Fire up Timer1 before entry to serial input routine
T1CON.0 = 1
I guess a question here would be how fast does a PIC receive DATA? At the moment we're only receiving the SYNCH - DAT_IN1 - DAT_IN2 & CHK_SUM BYTES. If for example when the project is running and we send accumalative Bird Box Visit_Data (day1 + day2 etc.....n) then after a Month we'd have 30 Bytes or Words even, would that time_out? Because as the program stands:
After the Data has arrived.Code:T1CON.0 = 0
Anyway moving on.
So the Data has arrived:
Then:Code:SERIN2 D_IN,N2400,[WAIT(Synch),DAT_IN1,DAT_IN2,CHK_SUM]
So Timer1 is stopped - TMR1H&L BYTES cleared.Code:T1CON.0 = 0 TMR1L = 0 TMR1H = 0
Before I carry on with **Begin Data Validaition**
What does the ! in: IF CheckSum ! mean please mackrackit.
Dave
Last edited by LEDave; - 21st November 2010 at 16:57.
Manual section
4.18. Comparison Operators
Not equal !=
I think once the PIC starts receiving with SERIN2 it will not stop till finished. I will have to check to be.I guess a question here would be how fast does a PIC receive DATA?
Dave
Always wear safety glasses while programming.
Cheers mackrackit, thanks for the pointer.Manual section
4.18. Comparison Operators
Not equal !=
Dave
Calculate checksum by adding 2 data bytes togetherSo the CheckSum = (%10101011 * 2 BYTES) if SW1 ( GPIO.3) was pressed.Code:CheckSum = DAT_IN1 + DAT_IN2
or (%10101101 * 2 BYTES) if SW2 (GPIO.4) was pressed.
Plus we should have the already have a calculated CHK_SUM that was sent.
So:
And:Code:CHK_SUM VAR BYTE ' Holds checksum received
Therefore:Code:CheckSum VAR BYTE ' Computed checksum of all bytes received
If Checksum (!) is not = CHK_SUM then go back to MAIN the checksum has failed.Code:IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
The same with:
The DAT_IN BYTES must also be equal, if not then back to MAIN:IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
If however everything matches then continue to MATCH..........
How does this look?
Dave
Last edited by LEDave; - 22nd November 2010 at 18:59.
Bookmarks