I've been working with ADuCM3029 until a few weeks and I'm using an ADuCM4050 microcontroller right now in a embedded system. Some APIs/drivers are different between them, so I had to update the firmware modifying some functions. However, I found a problem with UART, which cannot transmit data through serial port, (for example, printf() doesn't print anything), even using the internal loopback function I don't get the correct results. My team checked the hardware and it seems everything is OK, so maybe I have something wrong in my code and I can't find it.
The UART init looks like this:
void uart_Callback(void *pCBParam, uint32_t Event, void *pArg)
//Set TX as default
void UART_init(uint32_t *breakSleep)
/* Set the pinmux for the UART */
*pREG_GPIO0_CFG |= UART0_TX_PORTP0_MUX | UART0_RX_PORTP0_MUX;
/* Open the UART device.Data transfer is bidirectional with NORMAL mode by default. */
if(adi_uart_Open(0u, ADI_UART_DIR_BIDIRECTION, OutDeviceMem, sizeof OutDeviceMem, &hDevOutput)!=ADI_UART_SUCCESS)
/* Set UART to 115200 */
if(adi_uart_ConfigBaudRate(hDevOutput, UART_DIV_C, UART_DIV_M, UART_DIV_N,UART_OSR)!=ADI_UART_SUCCESS)
The main function starts with System, UART, I2C and SPI initialization followed by a while(1) loop with a printf("hello\n");.
Thank you all for your attention.
Please check the following:
You can use the "uart_loopback_example" included on EV-COG-AD4050LZ_BSP as a reference of your code.
Thank you for your message. The macro and the library are included in my code, so I've tried to execute the example that you cited. I also checked that drivers are fully updated.
While debugging, a Hard fault exception handler appears when it reaches this step:
/* Submit a filled buffer to the driver using DMA mode. This data will be what fills an empty Rx buffer. */
if(adi_uart_SubmitTxBuffer(hDevice, nBufferTx0, SIZE_OF_BUFFER, 1u) != ADI_UART_SUCCESS)
DEBUG_MESSAGE("Failed to submit Tx buffer 0 using dma mode.");
bResult = false;
I mean, that occurs when I try to execute the adi_uart_SubmitTxBuffer function.
Thank you for your attention.
Can you try to run the example code without stepping onto the code and see if the Hard fault error still occur.
I looked for which could be the cause of the problem. Taking a look at registers, I noticed the Hard fault error was produced by a memory management error. Then, I tried to run the SPI example code as another way to prove if the rest is all right and it didn't work properly, but modifying the icf file I got it works.
So, I think that the icf file is producing this situation. I'm going to review it and see what happens.
Thank you very much.