[BluePill+] problem with USART interrups
Posted: Sat Jul 12, 2025 9:19 am
Hi,
in my current project , I am dealing with RS485 , on my way. I am writing directly into the registers , in order to know exactly what I am doing , and what happens
The problem here is that after receiving a byte , the program stops ; I don't now if it is just before it enters the ISR (USART3_IRQHandler) ,or later .
I have put the same code in CubeIDE , it works , so I wonder what happens in STM32duino ? Thanks !
(my skills to debug in STM32duino are limited because of the terrible each time to compile)
in my current project , I am dealing with RS485 , on my way. I am writing directly into the registers , in order to know exactly what I am doing , and what happens
The problem here is that after receiving a byte , the program stops ; I don't now if it is just before it enters the ISR (USART3_IRQHandler) ,or later .
I have put the same code in CubeIDE , it works , so I wonder what happens in STM32duino ? Thanks !
(my skills to debug in STM32duino are limited because of the terrible each time to compile)
Code: Select all
/* rs.h x : rs485 on usart3 /* ua_rt.h */
#define DE485 PB12
void usart3_setup() {
RCC->APB1ENR |= RCC_APB1ENR_USART3EN; // Enable clock
// Configure PB10 (TX) and PB11 (RX)
GPIOB->CRH &= ~(GPIO_CRH_CNF10 | GPIO_CRH_MODE10 | GPIO_CRH_CNF11 | GPIO_CRH_MODE11); /// pas nécessaire ...
GPIOB->CRH |= (GPIO_CRH_CNF10_1 | GPIO_CRH_MODE10_0 | GPIO_CRH_CNF11_0); // alternate PP // input ... PU
// Configure USART3
USART3->BRR = 72000000 / 2 / 57600; // 57600 baud rate , APB1 is CLK/2
USART3->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE; // Enable TX and RX // Enable RXNE interrupt
USART3->CR1 |= USART_CR1_UE; // Enable USART
NVIC_EnableIRQ(USART3_IRQn);
pinMode(DE485, OUTPUT);
}
void USART3_IRQHandler(void) {
uint16_t data = USART3->DR;
Serial.print("USART3->DR:");
Serial.println(data);
}