I tested how is the grade of portability of Arduino C language on STM Core microcontroller board. FILE -> EXAMPLES -> LiquidCrystal -> HelloWorld.FILE -> EXAMPLES -> BASICS -> AnalogReadSerial.FILE -> EXAMPLES -> BASICS -> nd an information trough a Serial asure a voltage by internal ADC asure the voltage on a Digital input pin (BUTTON).change the state of a GPIO pin (BLINK a LED).In the Arduino IDE are built in simple examples like: I’m going to show what happen when you use Arduino C programming language on a STM32F401RE Nucleo board. To perform this task follow link: STM32Duino getting started Pin compatibility to Nucleo STM32F401RE Installing STM32 Core devices on Arduino IDEīefore to use STM32 Core microcontroller by Arduino IDE editing and programming platform, you have to upload as a new Device the STM32 Core Devices. More info on Nucleo development board following link: The image below assign some STM32 Nucleo F401RE version board pin as used on Arduino UNO board (Green coloured labels). Learn more about bidirectional Unicode characters. To review, open the file in an editor that reveals hidden Unicode characters. STM32 Nucleo-64 development board with STM32F401RE MCU, supports Arduino portability of Arduino to STM32 Nucleo F401RE pin Blink exampleīy powering On and Off alternatively one Arduino D13 aka Nucleo PA5 pin, you should see Green LED2 blinking (I noticed a labeling error on the official image above. NUCLEO-F401RE LED Blink Raw main.cpp This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. Base code generated with STM32CubeMX, code build and upload done with Segger IDE. the setup function runs once when you press reset or power the board LD1 is not attached to PA5/D13 pin, instead LD2). Simply blink LD2 when pressing blue button on Nucelo F401RE. the loop function runs over and over again foreverĭigitalWrite(LED2, HIGH) // turn the LED on (HIGH is the voltage level)ĭelay(100) // wait for a 100 millisecondĭigitalWrite(LED2, LOW) // turn the LED off by making the voltage LOW initialize digital pin LED_BUILTIN as an output. How fast is the pure blinking (no delay added). I measured 2us per high + low transition as in the image below. The speed of Arduino UNO pin is 7us per high + low transition as in the image below. Int buttonState = digitalRead(pushButton) ĭelay(1) // delay in between reads for stability the loop routine runs over and over again forever: initialize serial communication at 9600 bits per second: the setup routine runs once when you press reset: #define LED2 PA5 // digital pin Nucleo STM32F401RE #define pushButton PC13 // digital pin Nucleo STM32F401RE Nucleo board read pin PC13 attached to “user B1” button. If I try to use Serial monitor, Arduino IDE prompt an error. Using a cast like: uwTick += (unsigned long) HAL_TICK_FREQ_DEFAULT also works fine but then the write-protected stm32f4xx_hal.c has to be modified.I spent some hours around this communication problem and I’m embarrassed to say I was not able to fix it. The Keil MDK-ARM IDE ompiler has an option called 'Enum Container always int'. Adding uwTick with HAL_TICK_FREQ_DEFAULT results in adding a 16-bits or 32-bits value to it where only one byte is set to 0x01 resulting in unpredictable HAL_Delay() behaviour. But even if an enum is filled with say only one item declared as 1U (value 1 as unsigned long) then it will grab an unsigned char or single byte for it filling it with the value 0x01. The Keil arm compiler by default grabs that variable type (bit size) which can hold the largest number in an enumaration. If I replace this uwTick increment with HAL_TICK_FREQ_DEFAULT by increment with 1 then all works fine. This function increments the uwTick variable with the #define HAL_TICK_FREQ_DEFAULT. The HAL_IncTick() function is called about each 0.992ms (okay say 1ms). I connected a Saleae Logic Analyzer to some GPIO pins and made them toggle in different functions. It cost me 8 hours to find out why it did not work, but now it does.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |