• AVR Freaks

Hot!Receive USART buffer handler callback nor triggering when buffer is ready

Author
epareja
Super Member
  • Total Posts : 373
  • Reward points : 0
  • Joined: 2003/11/07 12:53:08
  • Location: Colombia
  • Status: offline
2020/02/26 21:29:12 (permalink)
0

Receive USART buffer handler callback nor triggering when buffer is ready

Hello,
 
I'm trying to implement a simple USART protocol with Harmony 2.06 in the PIC32MX795F512H and MPLAB IDE 5.30
 
I'm using the Queue Model support and the Interrupt flag enabled in the harmony configurator.
 
I set up the buffer handler like this 

 
 
 
    appData.usartHandle = DRV_USART_Open(DRV_USART_INDEX_0,
               DRV_IO_INTENT_READWRITE | DRV_IO_INTENT_NONBLOCKING);
    DRV_USART_BufferEventHandlerSet(appData.usartHandle,
               APP_BufferEventHandler, 0);
 
 
 

 
The generated interrupt function is like this:
void __ISR(_UART_5_VECTOR, ipl1AUTO) _IntHandlerDrvUsartInstance0(void)
{
    DRV_USART_TasksTransmit(sysObj.drvUsart0);
    DRV_USART_TasksError(sysObj.drvUsart0);
    DRV_USART_TasksReceive(sysObj.drvUsart0);
}

 
The ISR is called when receiving something from the USART port but the Buffer handler callback function is not called.
It's called only when transmits is completed.
This is my callback function:
void APP_BufferEventHandlerUsart(DRV_USART_BUFFER_EVENT buffEvent,
                            DRV_USART_BUFFER_HANDLE hBufferEvent,
                            uintptr_t context ) {
    switch(buffEvent)
    {
        /* Buffer event is completed successfully */
        case DRV_USART_BUFFER_EVENT_COMPLETE: {
          if (hBufferEvent == appData.drvUsartRxBufHandle) { // Check if RX was called
            Nop();
          } else if(hBufferEvent == appData.drvUsartTxBufHandle) { // Check if TX Buffer is finished
            Nop(); // **** I'm getting a breakpoint here *****
          }
          break;
        }

        /* Buffer event has some error */
        case DRV_USART_BUFFER_EVENT_ERROR:
            break;

       default:
            break;
    }
}

 
The read is programed when the driver is set up
 
        /* Add application Rx buffer to Usart1Driver Rx buffer and wait*/
        DRV_USART_BufferAddRead(appData.usartHandle,&(appData.drvUsartRxBufHandle),
        (uint8_t*)&appData.drvUsartRxBuffer[0],10);

 
Any help is appreciated.
 
post edited by epareja - 2020/02/26 21:37:40


Ernesto Pareja J
www.dcctrains.netne.net

#1

2 Replies Related Threads

    Paul PortSol
    Super Member
    • Total Posts : 578
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Receive USART buffer handler callback nor triggering when buffer is ready 2020/02/27 07:16:38 (permalink)
    0
    I use byte mode and callback works fine (It goes to my own ring buffer code).
    Sorry, no experience with the Harmony UART Queue Buffers.
     
     
    #2
    epareja
    Super Member
    • Total Posts : 373
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Receive USART buffer handler callback nor triggering when buffer is ready 2020/02/27 16:49:18 (permalink)
    0
    I found that it was a problem in the timing when to call the DRV_USART_BufferAddRead() function.
    DRV_USART_BufferAddRead(appData.usartHandle,&(appData.drvUsartRxBufHandle),
            (uint8_t*)&appData.drvUsartRxBuffer[0],10);



    In the app state machine I inserted a conditional to check if the application is completely configured and there is no more drivers to configure and in that point I call the BufferAddRead function and it's now triggering the event handler for reception.
    post edited by epareja - 2020/02/27 16:50:43


    Ernesto Pareja J
    www.dcctrains.netne.net

    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5