Why only a 2 byte hserin buffer? I'm communicating with MIDI (baud 31250) and I'm not seeing any way to check the hserin fast enough to prevent overflow. It over flows when I get a big packet of straight bytes.
Any tips or tricks?
Why only a 2 byte hserin buffer? I'm communicating with MIDI (baud 31250) and I'm not seeing any way to check the hserin fast enough to prevent overflow. It over flows when I get a big packet of straight bytes.
Any tips or tricks?
I read what you posted in the link. I saw the UART recieve interupt but I'm not sure what an interupt is and how it will help me.
eg
http://www.picbasic.co.uk/forum/showthread.php?t=11320
Then just put received chars in array
Code:Get_char: hserin 100,noreceived,[mybyte] 'Get byte MyArray[Index]=mybyte Index=Index+1 noreceived: 'or if timeout return @ INT_RETURN
Pedja089 ... Can you explain in more detail. What i think im reading is this code sets up the hserin to continously read into an array and the program simply needs to check that array?
When byte is received, PIC jump to Get_char, and get one char, and put it in array. Then PIC goes to do what it was doing before interrupt...
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
Hserin buffer 16F87x serires input and output buffers are each 47 bytes.
If you mean the hardware buffer, then NO. It is only 2 bytes deep.
Ioannis
Bookmarks