STM32L010 lpuart on PA14. AF not working???
I am trying to get the stm32L010 lpuart TX out of PA14. The datasheet says this is AF6. However, despite uart interrupts etc all working (so I assume the lpuart block is configured ok) I can get nothing on PA14. This isn't helped by the fact that PA14 is also SWCLK so debug is not possible.
However, PA14 can be used for GPIO. So, for IO initialisation I have done the following:
GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
// GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
// GPIO_InitStruct.Alternate = LL_GPIO_AF_6;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_14);and within LPUART1_IRQHandler() I have added:
// Transmit register empty
if(LL_LPUART_IsActiveFlag_TXE(LPUART1))
{
LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_14);
........ etc
}I can then see PA14 toggling on a regular basis indicating that the lpuart is running and transmitting the data I put in the buffer.
So now it should be a simple case of ensuring lpuart tx is on PA14 instead of the gpio right?
GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
// GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_6;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_14);You will noticed I left in the LL_GPIO_SetOutputPin(....) as the gpio output should be overriden by the alternative function setting.
Except it is not, I still get the GPIO toggling rather than any serial output.
I also tried setting AF4 (uart2, which is already trasmitting fine on PA3) and still only get GPIO activity on PA14.
Leaving the code as per the first section above (GPIO_Output) but then adding a
GPIOA->AFR[1] = (GPIOA->AFR[1] & 0xf0ffffff) | 0x06000000;on the end and it still makes no difference.
Basically, whatever I have tried, I cannot get any AF functionality on PA14. Any ideas on what I am doing wrong?