What pedja089 posted on #4 is a Interrupt Service Routine (ISR) that is part of a bigger program.
Interrupts might be a difficult subject for the novice, so you have to break your project in small parts and test each part, ensuring you understand the steps you take.
Darrel Taylor has put up this extremely helpful packet for 16 or 18 series PIC controllers but to understand how to do it you have to read a little.
Example (untested):
1. setup the ISR for the serial receive:
Whenever you are ready to receive characters place this commandCode:ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Get_char, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM
@ INT_ENABLE RX_INT
Your ISR could be the above posted:
Now every time there is a character available it will be put in the array mybyte untill the end is reached.Code:Get_char: hserin 100,noreceived,[mybyte] 'Get byte MyArray[Index]=mybyte Index=Index+1 If index>max_array-1 then index=0 flag_endarray_reached=1 EndIf noreceived: 'or if timeout return @ INT_RETURN
Then it will wrap arround and a flag will be set so you know that the array was filled up.
Don't forget to include the appropriate files of the DT-INTS for your chip used.
HTH,
Ioannis




Bookmarks