uart_interrupt example code hangs in main()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

uart_interrupt example code hangs in main()

Jump to solution
502 Views
stdcerr
Contributor IV

Hi,

 

I want to edit the uart_interrupt example to send and receive data using UART4.

I commented out the call to CLOCK_BootToPeeMode() inside BOARD_BootClockRUN() as we do not need this. I however realized, that the main loop now gets stuck at

 

/* Send data only when UART TX register is empty and ring buffer has data to send out. */
        while ((kUART_TxDataRegEmptyFlag & UART_GetStatusFlags(DEMO_UART)) && (rxIndex != txIndex))
{

 

where:

  •   DEMO_UART is set to UART4
  •  UART_GetStatusFlags returns 0xc00000c0
    • kUART_TxDataRegEmptyFlag is set to 0x80
  • rxIndex & txIndex are both 0

Should there not be an additional check to make sure that rxIndex & txIndex are not equal to 0?

Labels (1)
0 Kudos
1 Solution
481 Views
mjbcswitzerland
Specialist V

Hi

I would suggest that you are probably using the function incorrectly because it looks to be expecting txIndex to not be equal to rxIndex, which probably means that it is working with a ring buffer and txIndex means the index to the data that you put into the buffer and rxIndex means the index to the data that the lower level drive takes from the buffer and sends out over the UART.

If you haven't put data in to the buffer before calling this routine it will hang (by design).
Maybe you just need to first copy data to it first?

Another possibility is that you are using code designed to be used in a low priority task in a pre-emptive multi-tasking system which is polling the buffer to start sending out data that can be put into it by any higher priority task.

If you are using old KDSK examples it may be that you have a framework but it is only practically operational when you add additional code to do something (I experienced such things when solving problems for people a few years ago but I don't think anyone usually uses that library any more).).

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

View solution in original post

0 Kudos
1 Reply
482 Views
mjbcswitzerland
Specialist V

Hi

I would suggest that you are probably using the function incorrectly because it looks to be expecting txIndex to not be equal to rxIndex, which probably means that it is working with a ring buffer and txIndex means the index to the data that you put into the buffer and rxIndex means the index to the data that the lower level drive takes from the buffer and sends out over the UART.

If you haven't put data in to the buffer before calling this routine it will hang (by design).
Maybe you just need to first copy data to it first?

Another possibility is that you are using code designed to be used in a low priority task in a pre-emptive multi-tasking system which is polling the buffer to start sending out data that can be put into it by any higher priority task.

If you are using old KDSK examples it may be that you have a framework but it is only practically operational when you add additional code to do something (I experienced such things when solving problems for people a few years ago but I don't think anyone usually uses that library any more).).

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

0 Kudos