2024-07-14 10:53 PM - edited 2024-08-17 08:01 AM
[EDIT] displaying the values of the registers works on STM32duino arduino console
Hi ,
I am in the arduino world ; for some more particular tasks , the existing API is not enough , so I have to write my own code and debug it
I am trying to spy the actual value (setting) of some registers of some peripherals
this generally works , but I have a problem with USART2->CR1 : it always says value is "0" , but this is not possible , because USART2 is currently working !
Quetion : is there an other way to designate USART2->CR1 , in ordre to read the right value ?
this is the code : USART2 is outputed to a logical analyser , so can I see it really works
MCU is generic STM32G431CBUx ; thanks !
CODE: SELECT ALL
HardwareSerial Serial2(PA3, PA2); // configure USART2 uint64_t millis_duration = 100, millis_begin; // configure a 100ms tick void setup() { Serial.begin(115200); // USB to monitor delay(3000); Serial2.begin(250000); // PA2 USART2 Tx , to logical analyser } void loop() { if (millis() - millis_begin > millis_duration) { // debug USART2 millis_begin += millis_duration; Serial.println(USART2->CR1, BIN); // debug to monitor , display is always "0" ? Serial2.write(USART2->CR1); // can see the signal with logical analyser , confirms USART2 is working , confirms read CR1 value is false } }
Solved! Go to Solution.
2024-08-17 08:11 AM
the problem was that , I tried to configure the USARTs as receive only , but this is not an option at STM32duino , because it accepts only Rx + Tx pins mode , or single wire half duplex on Tx pin mode
so STM32duino did nothing , nor signalling an error
people wanting to use USARTs as Rx only , are terrible perverts
2024-07-15 12:34 AM
Are you sure USART2 = Serial2?
Try to read/print *all* USARTs' CR1.
JW
2024-07-15 02:00 AM
@mwalt.3 wrote:is there an other way to designate USART2->CR1 , in ordre to read the right value
Why not use the debugger?
Arduino IDE now supports the debugger - doesn't it?
2024-07-21 05:26 AM
it looks like there is something wrong in STM32duino with this (not so) particular MCU
in addition , STM32duino does not seem to support debugger , so I will switch to STM32cube for this project (will be back)
2024-07-22 02:55 AM - edited 2024-07-22 03:48 AM
@mwalt.3 wrote:it looks like there is something wrong in STM32duino
Have you reported this to them - on their forum and/or their GitHub?
2024-07-27 05:15 AM
I will do , after some further researches
what seams to be clear now :
- displaying the registers on arduino's monitor , works
- I am using the right variant , in order to configure the USARTS (putting a typo into the variant's file leads to a compiler error)
- nevertheless , STM32duino doesn't configure the USART , because USART1->CR1 is always 0
- and this , even for sure , as the corresponding bit is not set in the peripheral clock enable register
2024-08-17 08:11 AM
the problem was that , I tried to configure the USARTs as receive only , but this is not an option at STM32duino , because it accepts only Rx + Tx pins mode , or single wire half duplex on Tx pin mode
so STM32duino did nothing , nor signalling an error
people wanting to use USARTs as Rx only , are terrible perverts
2024-08-20 02:49 AM
@mwalt.3 wrote:STM32duino did nothing , nor signalling an error
Thanks for sharing the solution.
Have you fed this back to STM32duino ?
2024-08-30 02:04 PM
Hi , yes I did