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?
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.
Another question:
Bruce's code talks of Bank0 system. Am I correct in saying that BYTE $5F system is setting bit.5 of the STATUS REG to 0 which is selecting Bank0 ($5f = %1011111).Code:wsave VAR BYTE $5F system ' Saves W
So to change from Bank0 to Bank1 would be %1111111
Also:
So these commands mean Move the contents of the W REG to the address of wsave.Code:movwf wsave ; Save W
Mm, not really sure about this............(more reading to do).
Dave
Dave
Last edited by LEDave; - 22nd November 2010 at 23:43.
I think you got that part down.The DAT_IN BYTES must also be equal, if not then back to MAIN:
If however everything matches then continue to MATCH..........
How does this look?
Like I said, ASM is not my strong point. Not sure I have a strong point...Bruce's code talks of Bank0 system. Am I correct in saying that BYTE $5F system is setting bit.5 of the STATUS REG to 0 which is selecting Bank0 ($5f = %1011111).
So to change from Bank0 to Bank1 would be %1111111
Below tells how to change banks, I think.
Code:If the PICmicro has more than 2K of code space, an interrupt stub is automatically added that saves the W, STATUS and PCLATH registers into the variables wsave, ssave and psave, before going to your interrupt handler. Storage for these variables must be allocated in the BASIC program: wsave var byte $20 system wsave1 var byte $a0 system ' If device has RAM in bank1 wsave2 var byte $120 system ' If device has RAM in bank2 wsave3 var byte $1a0 system ' If device has RAM in bank3 ssave var byte bank0 system psave var byte bank0 systemYes.So these commands mean Move the contents of the W REG to the address of wsave.Code:movwf wsave ; Save W
Also notice that all of the data is restored in the opposite sequence it was saved.
If I am giving wrong ASM info , somebody please jump in and correct me!
Dave
Always wear safety glasses while programming.
Hi mackrackit,
Hey, you put up with me, so patience is one of themNot sure I have a strong point...
And don't forget it was trying to turn an LED on using ASM that after a near breakdown put me onto PBP
I'll go onto MATCH & DECODE tomorrow, slowly getting there (slowly).
Dave
It still doesn't take much to stump me I'm afraid........
When the Timer was set up for a 65ms reset we had:Code:MATCH = MATCH + 1 ' We have a match so increment match count IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good GOTO Main ' Else do it all over
Then the SYNCH_BYTE & DATA etc arrived and everything was good giving:Code:MATCH = 0 ' Clear match count
So to my mind that makes MATCH = 0 +1 ie 1.Code:MATCH = MATCH + 1 ' We have a match so increment match count
But then we have:
So either the data arrives twice within the 65ms time period to move onto DECODE or my understanding of MATCH = MATCH + 1 is wrong.Code:IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good
Help!
Dave
Bookmarks