I am trying to setup UART on an STM32L072CZTX. I am using interrupt mode and the interrupt seems to be firing due to a pause in main loop execution but nothing inside the interrupt seems to be occurring
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 6:32 AM
I am trying to setup UART on an STM32L072CZTX. In the ioc file I have setup the pins, RX is set to AF4 pullup, and TX is AF4 nopull. The interrupt is set to 0 and enabled. I have redefined the RxCpltCallback in the main and have events occur in there that work when run from main. I can see a pause in main execution (a simple blinking light) but nothing inside the interrupt seems to be happening, flags being set or a different LED blinking.
- Labels:
-
Interrupt
-
STM32L0 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9:43 AM
Polled UART Rx works?
A simple test, in main loop reading the UART Rx pin input state and setting/clearing LED accordingly, works?
LED blinky alone, works?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 10:16 AM
//__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
//HAL_UART_Receive_IT(&huart1, UART_RX_BUFFER, 20);
while (1)
{
HAL_UART_Receive(&huart1, UART_RX_BUFFER, 20, 10000);
HAL_GPIO_WritePin(GPIOB, GREEN_LED, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(GPIOB, GREEN_LED, GPIO_PIN_RESET);
Sending a message doesn't cause the block to exit and blink
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 10:31 AM
Well im not even reading a low pin state at any time so something might be setup wrong with my hardware
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 11:21 AM
Yeah more than likely you don't have the GPIO's set up correctly.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 11:36 AM
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
this is how theyre set up
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 1:24 PM
> this is how theyre set up
​
No. That is just some C code, calling other pieces of C code.
​
To find out how the GPIO is set up, read out and check/post content of its registers.
​
But check the HW first using continuity tester and oscilloscope.
​
JW​
​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 1:32 PM
If this init process doesn't tell me then what's the point of using it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 1:56 PM
See if the attached project works.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 8:20 PM
Well you have to set it up somehow, but when debugging, you always ​assume the relatively complex way from source code to executed binary may be wrong. The mcu works from the registers and not from C code, that's why the first thing when debugging is to read out registers and check.
​
But in your case, verify the hardware first.
​
JW​

- « Previous
-
- 1
- 2
- Next »