- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would like to use P9.0 and P9.1 for UART with the prototyping board. I have followed this example:
#define DATA_BITS_8 8
#define STOP_BITS_1 1
#define TX_PIN P9_1
#define RX_PIN P9_0
#define BAUD_RATE 115200
#define UART_DELAY 10u
#define RX_BUF_SIZE 4
#define TX_BUF_SIZE 4
/* Variable Declarations */
cy_rslt_t rslt;
cyhal_uart_t uart_obj;
uint32_t actualbaud;
uint8_t tx_buf[TX_BUF_SIZE] = {'1','2','3','4'};
uint8_t rx_buf[RX_BUF_SIZE];
size_t tx_length = TX_BUF_SIZE;
size_t rx_length = RX_BUF_SIZE;
uint32_t value = 'A';
/* 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 = rx_buf,
.rx_buffer_size = RX_BUF_SIZE
};
/* Initialize the UART Block */
rslt = cyhal_uart_init(&uart_obj, TX_PIN, RX_PIN, NULL, &uart_config);
/* Set the baud rate */
rslt = cyhal_uart_set_baud(&uart_obj, BAUD_RATE, &actualbaud);
/* Begin Tx Transfer */
cyhal_uart_write(&uart_obj, (void*)tx_buf, &tx_length);
cyhal_system_delay_ms(UART_DELAY);
But I am running into Cy_SysLib_ProcessingFault() at the cyhal_uart_write() line.
Am I missing something?
Solved! Go to Solution.
- Tags:
- psoc6 uart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi SySa_4665481,
I used your code in an empty project and programmed the device. I was able to observe the data on the UART pins.
Have you enabled/configured the P9_0 and P9_1 pins in the Device Configurator? Can you please import an empty project, paste your code and let me know if it works?
Also, can you share your entire project so that I can have a look?
Thanks and Regards,
Rakshith M B
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi SySa_4665481,
I used your code in an empty project and programmed the device. I was able to observe the data on the UART pins.
Have you enabled/configured the P9_0 and P9_1 pins in the Device Configurator? Can you please import an empty project, paste your code and let me know if it works?
Also, can you share your entire project so that I can have a look?
Thanks and Regards,
Rakshith M B
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi RakshithM_16,
Thank you for confirming.
You're right, it works. Turns out I did a silly mistake by passing an integer value as the last parameter to cyhal_uart_write() when it expects a pointer and this caused the fault.
Cheers,
Syafii
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Syafii,
Thank you for providing an update on this thread!
Best regards,
Rakshith
Rakshith M B