Showing posts with label Microcontroller. Show all posts
Showing posts with label Microcontroller. Show all posts

Sunday, December 7, 2014

BRTOS with Nucleo F401RE

I creaded a small demo for testing the BRTOS (Brazilian Real-Time Operating System) in my Nucleo board with Coocox COIDE and ARM GCC.

BRTOS is a  lightweight preemptive real time operating system designed for low end microcontrollers.

More info about BRTOS:

https://code.google.com/p/brtos/

https://brtosblog.wordpress.com/

In this demo, clock is configured as:

External 8MHz from STLINK V2.

  • Main clock: 84MHz
  • AHB clock: 84MHz
  • APB1 clock: 42MHz
  • APB2 clcok: 84MHz
  • Timers clock: 84MHz
  • SDIO clock: 48MHz


Check more info about clock config for NucleoF401 in this post.
Flash Prefetch enabled and 2 wait states (minimum for 84MHz and 3.3V).

This demo uses two tasks. One of them flashes the LED and prints a string with a counter in serial every second.
The second task is used to handle the user button switch press event. When the user press the button a string is printed in serial.
Using a mutex to avoid conflicts with two tasks sharing the serial.
Serial used is USART2 that is connected in STLINK V2-1 and becomes a Virtual Serial Com port when STLINK is connected.

The demo code is hosted at my GitHub account:

https://github.com/miguelmoreto/NucleoF401-COIDE-BRTOS

Tuesday, January 14, 2014

DHT22 Blocking Library for AVR

Some time ago a updated a DHT22 library posted at AVRFreaks forum. That lib returned float values which inplies that the AVR-GCC added a very large library. The code size was above 2kB.
With this update, float number is not needed anymore and the lib returns the integral and decimal parts of the values in a defined struct format. Is needed, the user can configure the lib to return raw values from the sensor. Code size now is only around 300 bytes.

DHT22 Interrupt Driven library for AVR

This lib can read temperature and humidity of a DHT22 sensor without blocking the microcontroller with unnecessary delay functions. The lib is interrupt driven, all the timing measurements of sensor signal is done with a timer and a external interrupt using a state machine.

This way, you can use this lib with multiplexed displays without flicker the display during the measurement of the sensor data.
I hope this lib can be useful to someone.