Hi, I am using an LPC865M201JHI48 customized microcontroller board. I copied the SDK example of the LPC865 USART polling method and used it in my code. However, it is transmitting some garbage values. For example, if I transmit 'a', I receive '0' on my serial terminal software, PuTTY. I am unable to understand some parts of the code. Can anyone explain which registers should be configured in the
USART_Init(EXAMPLE_USART, &config, EXAMPLE_USART_CLK_FREQ); function? Why are we using the default configuration function USART_GetDefaultConfig(&config); ?
Hi @BerlinRaj
USART_GetDefaultConfig(&config)
This function is used to obtain the common default configuration. You can also customize the configuration according to your needs.
USART_Init(EXAMPLE_USART, &config, EXAMPLE_USART_CLK_FREQ)
This function initializes USART based on the previous configuration.
As you mentioned "f I transmit 'a', I receive '0' on my serial terminal software, PuTTY."
I completely agree with @frank_m, you should observe the output signal through an oscilloscope, which can show both the clock frequency and the bit.
Hope this will help you.
BR
Hang
I am using the internal oscillator. That may be the reason for the issue?.
This might well be.
I don't have a LPC865 eval board, much less your custom board.
But a change in the clock tree surely affects all peripherals, whose clock generation is derived (usually) from the core clock.
As said, I highly recommend to check the UART signal with a scope. It will also reveal the actual baudrate.
> Hi, I am using an LPC865M201JHI48 customized microcontroller board. I copied the SDK example of the LPC865 USART polling method ...
You will have to make sure the SDK example applies (correct MCU and ext. quartz oscillator), and that that your custom board design is correct so far.
> However, it is transmitting some garbage values. For example, if I transmit 'a', I receive '0' on my serial terminal software, PuTTY.
Take a scope and measure actual signal. Otherwise you are just poking around in the dark.
Both baudrate and signal level could be incorrect. A 3.3V MCU output is not able to drive a TTL level input of a serial adapter.
> // USART0->CFG &= ~(0x30);//NO PARITY
> ...
I'm not going to decode the bit operation with the datasheet / user manual.
Start with the actual UART signal.