lunedì 30 luglio 2012

Mp3 Player with scrolling menu from scratch (Beatstream 2.0)

Developed by Gian Marco Iodice
Electronic engineering student at University of Pisa (Italy)

For any question contact me:

The Beatstream 2.0 is the update of "Beatstream" project. The first version was created in June 2011 and concerned the development of “wav audio player” with STM32 (STM) MCU without O.S.. Since the the pins associated to DAC was already used by LCD on the board, I decided to implement a software DAC with PWM peripheral at 10 bit resolution. Also, for the oldest version of Beatstream, I created:

  1. GUI (with drag finger scroll) - This GUI was not portable to other platform 
  2. Library to decode wav file
  3. Driver for resistive touch screen (GetCoordinate(), Calibration()...)
  4. Driver for SDcard - I used FATFS module by elm-chan to manipulate file (open, read, write file)

The new version of Beatstream started in Junuary 2012 in parallel with the development of "Gooey" Lib.
Gooey is a computer graphics library for embedded syystem written in C and completely separated from I/O layer to guarantee the easy portability on any architecture. It was written from scratch with low level approach and it can be incorporated into low cost MCU without O.S. or used under Linux or Windows environment, enabling optional support of SDL library. Contains a collection of functions and data structures that covering the main features of a basic computer graphics and computer vision. The name of this library it was inspired by pronunciation of GUI but is not only a graphic user interface but a set of modules, such as GUI, that helps the user to cover a lot of application in the world of computer graphics and computer vision.
The library is LCD resolution indipendent and works only with 16 bit (RGB565) pixel depth.
It is composed by these modules:

  1. GUI - Allows support for scrollable-menu, list of file and widget such as progress bar, scrollbar
  2. Image processing - Allows to have a set of functions for most image-processing techniques that involve treating the image in two-dimensional. It is under construction
  3. Image decompressor - At this moment support only Bmp and Jpeg format and it is under profiling

The programmer, with some pre-processor directive, can decide which modules and which components of this compile.

The lib Gooey support Antialias Font.
Gooey is used with Beatstream 2.0. In the new version of audio player, also, it was included Mp3 and Wma decoder. The new mp3 player works WITHOUT O.S., and it was developed with the same board of first version.


The MP3 player was developed with:

1. STM32F1x microcontroller with ARM cortex M3 core. The microcontroller works with 72 MHz and has 512 Kbyte of Program Memory and 64 Kbyte of Data Ram

2. ILI9325 as LCD controller

3. TSC2046 as touchscreen controller. The controller works with SPI protocol

4. VS1003 as co-processor to decode audio files

Some peripherals of microcontroller are: 

1. PWM

2. Timer

3. Flexible static memory to interface Flash, SRAM, PSRAM, NOR and NAND memories. This is used to interface ILI9325

4. Serial data interface as SPI, I2C, UART..

5. 12 bit DAC/ADC

6. SDIO to interface microsd, SDcard

7. ...

Some features of Gooey are:

  1. Intuitive APIs for C language 
  2. Optional support for SDL library under Windows or Linux O.S.
  3. Platform independent and then easy to port to other platforms
  4. Support for Frame Buffer or External display controller
  5. Draw geometric primitive as line, point, circle, rectangle.. and print string, with different font and color, and image
  6. Support Antialias Font
  7. Clip of Image or geometric primitive in particular display area 
  8. Image's animation (similar to Powerpoint animation). You can configure a type (fade, bounce, fly, slide...) and anchor's point of animation
  9. Chroma key support 
  10. Widget (Scrollbar, Progressbar...) 
  11. Create menu or items list with only 4 functions. There are 2 different menus: “Scrollable” and “Simply”. The first is perfect for touchscreen or pointing devices and is based on “Gooey scrolling”. This is composed by click (or touch) & drag scrolling with an additional movement after the finger is lifted off the screen. The movement, after lifted off the screen, is based on how fast the finger was dragged on the screen. The duration, speed and deceleration are customizable with some pre-processor defines. The scrolling works with the same timing on different machine. In this mode you can have the same reactivity independently of the performance of system. However the smooth of animation increases with the increase of computational capabilities. Below link to video that show “Gooey scrolling” on Ubuntu with the support of SDL library. The second menu can be use with system based on keyboard or infrared remote.

Antialias Disable (16 bit depth)

Antialias Enable (16 bit depth)

Since the GUI is completely separated from I/O layer, it requires the following functions provided by user. 

1. EXTAPI_Delayms(); // delay millisecond 

2. EXTAPI_CheckTouch(); // check touch display 

3. EXTAPI_GetCoordinate(); // return the coordinate of touch 

4. EXTAPI_CheckButtonPress(); // check button press 

5. EXTAPI_GetButtonPress(); //return button press 

6. EXTAPI_StartTime(); // start millisecond timer 

7. EXTAPI_StopTime(); // stop millisecond timer 

8. EXTAPI_SnapshotTime(); // return value of timer in millisecond

To decode Mp3/Wma files I used an external VLSI (VS1003) co-processor. VS1003 is a single-chip Mp3/Wma/MIDI audio decoder and ADPCM encoder that works with SPI protocol. VS1003 receives its input bitstream through a serial input bus, which it listens to as a system slave and decode it. I have implemented a driver to control this chip.

lunedì 12 settembre 2011

Stm32(cortex m3) project: Touchscreen click & drag scrolling with microcontroller Stm32

This is a continue of "beatstream project". I've update firmware implementing library to create fully customizable window (size and position window, color bar, header, background,object select,font) with touchscreen scroll. You can scroll up and down to select your item. The effect is similar to Iphone or android mobile (obviously not the same! XD ). The entire project works without O.S..Contact me for info or comment ( always welcome ).

venerdì 2 settembre 2011

STM32 ( cortex M3 ): microsd card touchscreen audio player with spectrum display

This is an update of project STM32: microSD Wav audio player with touchscreen.This version has a spectrum display during playback. I used DSP library for ARM Cortex-M3 based STM32 microcontrollers available from ST Microelectronics website. This license-free, and royalty-free DSP library holds large number of valuable functions coded in C or assembly language (as FFT ) including PID controller, Fourier transform functions, and a selection of digital filters such as 16-bit FIR, IIR direct-form, and IIR canonical-form filters.
The DSP library can be used with the IAR, Keil Toolchain for the STM32.
Alternative DSP functions for Cortex M3 are avaible at

mercoledì 31 agosto 2011

DAC PWM glitch problem with STM32

With the project STM32: microSD Wav audio player with touchscreen I use microcontroller's PWM as 10 bit DAC but in first version of firmware I have found an annoying glitch during playback.

(coming soon video with glitch problem)

This problem is typical when you use TIM_OC1Init(TIM1,&TIM1_OCInitStructure) function to obtain PWM with costant frequency and variable duty cycle.

To solve this problem you can follow these steps:
First step: The initialization code

The initialization code is:

TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef  TIM_OCInitStructure;


/* Time Base configuration */
TIM1_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM1_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;
TIM1_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM1_TimeBaseStructure.TIM_Period = 1020;

/* Channel 1,3 Configuration in PWM mode */
TIM1_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM1_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM1_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM1_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM1_OCInitStructure.TIM_Pulse = 1024/2;



TIM_OC3Init(TIM1, &TIM1_OCInitStructure);

/* TIM1 counter enable */

Second step: Update Duty cycle periodically
After initialization, if you want to update duty cycle periodically, you don't use a TIM_OC1Init(TIM1,&TIM1_OCInitStructure) function because you load all field of TIM1_OCInitStructure struct losing firmware efficiency inevitably and causing a glitch during playback but you must update the PWM writing the registers directly as follows:

TIM2->CCR2 = duty1;
TIM2->CCR3 = duty2;



lunedì 29 agosto 2011

TI Stellaris 8962 : microSD Wav audio player with PWM DAC

Stellaris 8962 is a TI's microcontroller with cortex m3 core.
The evaluation board LM3S8962 has OLED grayscale display(4bit 128 x 96), microSD adapter, 6 buttons(including reset), CAN, buzzer, Ethernet,Usb...
The board has an In-Circuit Debug Interface (ICDI) that provides hardware debugging functionality
The project play song on microSD with PWM's DAC. For this project I created template and firmware.
Display and microSD share same SPI.

STM32 ( cortex m3 ): piano with touchscreen and PWM

Play Piano with touchscreen!! I used PWM to generate a note.
I used a GUI, touchscreen library created for a project STM32: microSD Wav audio player with touchscreen .
Varying the frequency of PWM you can generate a single note.
For frequencies click on this link.

giovedì 25 agosto 2011

STM32: microSD Wav audio player with touchscreen

For this project I created GUI, touch screen library, template to develop a touch screen user interface (icons, menu, progress bar, font) and a firmware to play song .wav( I used PWM as 10 bit DAC to convert a sample in analog voltage).
I used module FATFS for the file system FAT32 on microSD.