2019-03-26 03:38 PM
Hello:
I am trying to determine why the LPUART is transmitting out the values I am seeing. They make little sense. Here is the UART setup:
void MX_LPUART1_UART_Init(void)
{
hlpuart1.Instance = LPUART1;
hlpuart1.Init.BaudRate = 9600;
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
hlpuart1.Init.StopBits = UART_STOPBITS_1;
hlpuart1.Init.Parity = UART_PARITY_NONE;
hlpuart1.Init.Mode = UART_MODE_TX_RX;
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&hlpuart1) != HAL_OK)
{
Error_Handler();
}
}
MX_LPUART1_UART_Init();
For the purposes of testing, I want to transmit an 'A':
//assert the direction line on the transceiver high for transmit
HAL_GPIO_WritePin(COM_DIR_GPIO_Port, COM_DIR_Pin, GPIO_PIN_SET);
vTaskDelay(1); //small amount of delay
//transmit the letter A
HAL_UART_Transmit(&hlpuart1, (uint8_t*)'A',1,0xFFFF);
At the output of the L433, this is not at all what I am seeing. I have attached a scope capture.
If the first bit out is 0, then: 11001110, then bit high.
It does this consistently. The Tx, Rx are connected to a RS-485 transceiver, connected to an adapter to my PC, and using Teraterm set up same as the L4, it displays an 'F', which makes less sense. The second capture is the scope showng the RS485 tx. When zoomed in on the transitions, the bit transitions are the same as the tx line into the transceiver, other than the transmit control assert line transition.
I would appreciate any help or suggestions as to what might be going on, thank you.
FYI - it is being operated in RUN mode, not stop.
2019-03-26 05:02 PM
(uint8_t*)"A" not (uint8_t*)'A'
2019-03-26 05:04 PM
> (uint8_t*)'A'
You transmit whatever is at address 0x00000041.
JW
2019-03-26 06:13 PM
Thanks for answers guys, I had an array in a loop and wanted to use one character. Oops. So the character is now getting transmitted out, I can see it on the scope going into the transceiver.
Now I am back to the original issue, which is what appears to be a mismatch in UART speeds.
I discovered the issue was the TVS I was using on the 485 side of the transceiver. I had this in addition to the standard 120 ohm resistor. It was clamping too hard and trashing the signals, making it look like a mismatch in speeds. After removing it, all is well. The TVS was clamping a bit too close to the signal levels, will need to change it.
Thanks again for your time.