SCB UART addressing

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

cross mob
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hello Cypress,

I would really appreciate some help with an issue I have on addressing a UART resource in the SCB4 block.

The UART is configured using the Device Configurator which also generates code for it. 

Seems like I do not register the interrupt correctly as the MCU throws a "cannot address memory" error when

Cy_SCB_UART_Interrupt(scb_4_HW, &uartContext); is called.

I have not found any working example that uses an UART configured with the Device Configurator. Any idea on how to

correctly address this resource ? Could be that scb_4_HW, which is generated by the Configurator, is not the correct

address to reach the configured UART ?

Thanks for any hints

Stefan

0 Likes
1 Solution
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

The UART configured in the Device Configuration including respective pins make a successful cyhal_uart_init (as well using the PDL API) impossible as the pins will be reserved. Need to disable the pins, at least, in the Device Configurator. But leave them named. These names can then be used to successfully init the UART with any of the APIs

View solution in original post

0 Likes
4 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Stefan,
Cy_SCB_UART_Interrupt(scb_4_HW, &uartContext);  should have worked once SCB4 has been configured. Make sure you are not using any aliases. If yes try the code as below.

Cy_SCB_UART_Interrupt(SCB4, &uartContext);

Meanwhile I am adding below PDL documentation interrupt section for your reference.

Configure Interrupt

The interrupt is optional for the UART operation. To configure interrupt the Cy_SCB_UART_Interrupt function must be called in the interrupt handler for the selected SCB instance. Also, this interrupt must be enabled in the NVIC. The interrupt must be configured when High-Level API will be used.

void UART_Isr(void)
{
Cy_SCB_UART_Interrupt(SCB5, &uartContext);
}
/* Assign UART interrupt number and priority */
#define UART_INTR_NUM ((IRQn_Type) scb_5_interrupt_IRQn)
#define UART_INTR_PRIORITY (7U)
 
/* Populate configuration structure (code specific for CM4) */
cy_stc_sysint_t uartIntrConfig =
{
.intrSrc = UART_INTR_NUM,
.intrPriority = UART_INTR_PRIORITY,
};
 
/* Hook interrupt service routine and enable interrupt */
(void) Cy_SysInt_Init(&uartIntrConfig, &UART_Isr);
NVIC_EnableIRQ(UART_INTR_NUM);
 
Best Regards,
Vasanth 
0 Likes

Hi Vasanth,

do you by any chance know how to change the LSB First to MSB First for the cy_retarget_io_uart_obj ?

I was able to get that to work with P8_0 and P8_1 oft the Wifi BT Kit.

Thanks

Stefan

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hello Vasanth, I found the source of the problem now. Even using the high level api I cannot use an UART in SCB4 which I have configured in Device Configurator:

/* Initialize the UART configuration structure */
const cyhal_uart_cfg_t uart_config =
{
.data_bits = DATA_BITS_8,
.stop_bits = STOP_BITS_1,
.parity = CYHAL_UART_PARITY_NONE,
.rx_buffer = rxBuffer,
.rx_buffer_size = UART_RX_BUFFER_SIZE
};

rslt = cyhal_uart_init(&uart_obj, CYBSP_UART1_TX, CYBSP_UART1_RX, NULL, &uart_config);
if(rslt != CY_RSLT_SUCCESS)
{
handle_error();
}

This code fails because the pins are already reserved by the Device Configurator. If I undefine the pins and UART in device configurator then at least the cyhal_uart_init works. However, I need to be able to configure also the MSB_first which I cannot set in the uart_config above.

Would you please provide me with

an example on how to initialize and use an UART which is configured through the device configurator ?

Is the call to cyhal_uart_init unnecessary ? If yes, how do I then address the uart in e.g. cyhal_uart_write ?

Thank you very much for any help

Stefan

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

The UART configured in the Device Configuration including respective pins make a successful cyhal_uart_init (as well using the PDL API) impossible as the pins will be reserved. Need to disable the pins, at least, in the Device Configurator. But leave them named. These names can then be used to successfully init the UART with any of the APIs

0 Likes