How to fixlow level array write to UART

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RuPi_283656
Level 4
Level 4
25 sign-ins 10 sign-ins First solution authored

Hi all.  I'm having a problem with the Cy_SCB_UART_PutArrayBlocking function.  This is with the BLE pioneer wifi, kit2.  I can trace through all the sub functions with the debugger, and it looks like everything is working correctly, but nothing gets written from the UART.  I am able to receive data with no problem though.  Here is my setup - is there something more I need?

init_status = Cy_SCB_UART_Init (UART_HW, &UART_config, &UART_context);
if (init_status != CY_SCB_UART_SUCCESS) {
    do {
      Cy_GPIO_Inv (LED_Red_P0_3_PORT, LED_Red_P0_3_NUM);
      CyDelay (50);
    } while (true);
}

Cy_SCB_UART_Enable (UART_HW);

// Unmasking only the RX fifo not empty interrupt bit
UART_HW->INTR_RX_MASK = SCB_INTR_RX_MASK_NOT_EMPTY_Msk;
Cy_SysInt_Init (&UART_SCB_IRQ_cfg, &ISR_UART); // Interrupt Settings for UART
NVIC_EnableIRQ (UART_SCB_IRQ_cfg.intrSrc); // Enable the interrupt

__enable_irq (); // Enable global interrupts.

 

The interrupt handler works as expected. After receiving a command to send data:

 

if (bExecute) {
    // Process the data through the CFFT/CIFFT module
    arm_cfft_f32 (&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse);

    // Process the data through the Complex Magnitude Module for
    // calculating the magnitude at each bin
    arm_cmplx_mag_f32 (testInput_f32_10khz, testOutput, fftSize);

    // Calculates maxValue and returns corresponding BIN value
    arm_max_f32 (testOutput, fftSize, &maxValue, &testIndex);

    if (testIndex == refIndex) {
      Cy_SCB_UART_PutArrayBlocking (SCB5, testOutput, fftSize);
      // Blocking wait for transfer completion
      while (!Cy_SCB_UART_IsTxComplete (SCB5)) {}
}

As I said, the last line above completes, the system thinks all the data was sent properly, but nothing is sent.

I had this working in a previous project, but the difference is that there I was using high level UART functions.

There seems to be some confusion about that.  In the UART data sheet it clearly says that high level functions are to be used when the interrupt mode is internal, and low level when the mode is external.  However the example code shows using low level functions with the internal mode.  I am using internal mode, and indeed it works, for receiving data.  Also, the high level example code shows using Cy_SCB_UART_PutArrayBlocking, even though it is supposed to be a low level function!  The PDL definitely states not to mix the low and high level functions.  So it is confusing.

Should my code work?  If not, why.

Thanks, Russ

0 Likes
1 Solution
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @RuPi_283656 ,

We suggest you using external UART- interrupts instead of internal in your project. You can refer the code example "UART Using low level APIs" here : https://www.cypress.com/documentation/code-examples/ce219656-psoc-6-mcu-uart-using-low-level-apis for the implementation part.

>> However the example code shows using low level functions with the internal mode. 

-> I assume you are following "UART Using high level APIs". The code example uses UART low level APIs such as  Cy_SCB_UART_PutString() just for the  debugging and printing statements. Please do not mistake it for this that the entire code example uses low level API. However, you can check in the code example that for the transmit and receiving of bytes during communication, the high level APIs have been used. For more information on UART PDL APIs, please refer here : PSoC 6 Peripheral Driver Library: UART (SCB)

Also, Can you please attach your project so that we can check the issue on our end? 

Best Regards,

Aashita

 

 

 

View solution in original post

0 Likes
1 Reply
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @RuPi_283656 ,

We suggest you using external UART- interrupts instead of internal in your project. You can refer the code example "UART Using low level APIs" here : https://www.cypress.com/documentation/code-examples/ce219656-psoc-6-mcu-uart-using-low-level-apis for the implementation part.

>> However the example code shows using low level functions with the internal mode. 

-> I assume you are following "UART Using high level APIs". The code example uses UART low level APIs such as  Cy_SCB_UART_PutString() just for the  debugging and printing statements. Please do not mistake it for this that the entire code example uses low level API. However, you can check in the code example that for the transmit and receiving of bytes during communication, the high level APIs have been used. For more information on UART PDL APIs, please refer here : PSoC 6 Peripheral Driver Library: UART (SCB)

Also, Can you please attach your project so that we can check the issue on our end? 

Best Regards,

Aashita

 

 

 

0 Likes