Hi everyone, i have some weeks working with FreeRTOS. i’m ussing MPLAB C18 and now i have the next problem.
I’m ussing ISR for RX USART, i have used in the past in a normal project for MPLAB C18 but now i have to do it with freeRTOS and C18, I activate the ISR for USART from the port.c file:
/*
* Vector for ISR. Nothing here must alter any registers!
*/ #pragma code high_vector=0x08
static void prvLowInterrupt( void )
{
/* Was the interrupt the tick? */
if( PIR1bits.CCP1IF )
{
_asm
goto prvTickISR
_endasm
}
when i enter in the interrupt (the program work and enter when the USART receive data) i put the PIR1bits.RCIF=0 for wait a new reception, but i can’t put the register in 0 is ever en 1 and the interrupt is ever entering even when i’m not receiving data.
Normally, you need to take the character out of the RxBuffer before clearing the interrupt flag. so you want something like: (I am guessing on port names)
if(PIR1bits.RCIF){
while(! PIR1bits.rxempty){
char c;
c = PIR1.rxbuff;
/* put code to process character here, either send to queue or build message in a buffer */
}
PIR1bits.RCIF = 0;
}
Since the buffer isn’t empty, the port will assert the interrupt again immediately.
i get the data and clean and set CREN stat bit because if i don’t when i receive two o more bytes the recepcion crash, i have create a task for process the byte and only print in the display when i receive the valor i’m expecting.