Sunday 30 October 2016

USB Boot Loader (Device-Firmware-Upgrade) for STM32F103C8T6

USB Boot Loader (Device-Firmware-Upgrade) for                                                  STM32F103C8T6

STM32F103C8T6 is most popular cheap and best micro-controller based on ARM-Cortex-M3 core
It is also called as minimum development board or Bluepill it can be used to do mini projects.
from ST official website you can get datasheet and software for this board.Key features of this board 
it got multiple serial communication protocols like
1) USART   2) USB     3)SPI     4)I2C     5)CAN
also has 7-channel DMA support with moderate on chip memory of RAM-20KB, FLASH-64KB
by default it has USART bootloader.
To program it through USART ISP one should set two yellow jumpers in above diagram in following position
Boot0-High
Boot1-Low

For programming this device either you can use ST-Link or USB to TTL Serial Converter 



It also has Micro USB port but by default it can be used only to supply power to board. Here i will show how to add secondary bootloader to STM32F103C8T6 (bulepill) board so that you can use same USB cable to power up as well as to program board at the expense of loss of  few KB  flash. First 12KB of flash will be occupied by this secondary boot loader.

Softwares that are required to add DFU support to STM32F103C8T6 
1) STM FlashLoader- Download from STsite   
2) STM USBdfuse - Download from STsite
note you should register to download from ST which is simple process (free)
3) IDE i will use Keil uv , you can get it from here  select STM32F1xx pack
4) STM DFU Firmware.hex - Download
Initially Install first three softwares  after installation you may find STMicrocontroller
 softwares in this path C:\Program Files (x86)\STMicroelectronics\Software
just go to Flash Loader Demo folder and pin STMFlashLoaderDemo.exe to task bar
similarly go to DfuSe v3.05 folder -> Bin folder  and pin DfuFileMgr.exe and DfuSe Demo.exe to Taskbar. 
Then open  STM FlashLoader to flash controller with STM DFU Firmware.hex
Initially this has to be done through USART0 
pins PA9-Tx of board must be connected to Rx of USB to Serial Converter
pins PA10-Rx of board must be connected to Tx of USB to Serial Converter
and by keeping Boot0 high Boot1 low press reset 
open FlashLoader.exe
you should get this kind of info on screen
Press reset button on board  and click on next  
you should get response like this
If you get no response from device
Troubleshoot: then click on ok and change echo to echo mode press reset and click next again you will get no response. This time revert it to echo disabled and press reset on board and immediately click next you will get above mentioned response.
   then click next

It will recognize STM32F103C8T6 as medium density device click next

check Download to device and click on open  menu to select DFU.hex
click next.
you should get response as Download operation finished successfully then click on close.
now change boot0 position to logic 0 .
Go to C:\Program Files (x86)\STMicroelectronics\Software 
DfuSe v3.05 folder and click on drivers based on Processor type 64 or 32bit and Windows type go to appropriate Drivers folder and install drivers.

Since it is secondary bootloader entrypoint is based on PB9 pin when you connect USB to system make sure that PB9 kept floating If it is connected to ground DFU drivers will be skipped and application code will be executed.


open DFUse Demo you should see Internal flash of 64KB 
Since Secondary bootloader takes 12KB you have to follow few modifications in application code

System_stm32f10x.c change VECT_TAB_OFFSET to  0x3000

under options for target change IROM from 0x8000000 to 0x8003000 

also check Linker option use memory layout from target dialog
thats it click on to generate hex 

and open DFU file manager to convert Hex to DFU file



then click on generate .dfu file
save with some name and extension as .dfu it will give success message

then use Dfuse demo to upload code in to flash



check on Verify after download and Optimize Upgrade duration
you should get verify successful then click reset so that application code will be executed
 that's it you can do program by using same usb cable


  Programming Tutorial can be followed from here

NOTE: DFU.hex is password protected whoever wants it can post their email id under comments section. 

Indonesia -done
Ukraine-done
Russia-done
Czech republic-done
Argentina-done
I am glad that I could interact with people of these countries.Hopefully I could help somemore in future.

Wednesday 26 October 2016

Interactive Voice Response system

Interactive Voice Response System (Automation using GSM-DTMF Decoder)

Old is Gold, Old model GSM phones(2 quantity) can be used to make this simple automation project.
Modules required:
Old Model GSM phones (2)
DTMF Decoder Module(1)
Microcontroller(1)
Voice Record and Playback module(1)

 In old mobile phones each key is associated with two frequencies those frequencies can be decoded by using DTMF Decoder. Also to guide user Voice record and playback module is required

1) Old Model GSM phone:
Old Model phone must be configure with following settings
 - Settings->Keypad Tone->set it to maximum value
- Settings-> Enhancement Setting-> set Auto Answer option on headset

2) Voice Record and Playback module:
In this project i used APR33A3 which has 8 channels and can record audio of 1.2Mins duration
record some voice in each channel like instructions
 - Press 1 to turn on Light
 - Press 2 to turn off Light
 etc there is toggle switch to select record/playback mode
while recording select record mode and also each channel is provided with press button
hold particular channel press button to record voice
then change toggle switch to playback mode
and give active low signal to previously recorded channel then you can get recorded voice

3) Interface DTMF Decoder APR33A3 modules to Microcontroller as shown


Call to Mobile phone which is conected to DTMF decoder then automatically it will lift the
call that will activate APR33A3 module that will guide user accordingly  press particular key in
your mobile phone that will be decoded by DTMF decoder. based on that microcontroller has to controll electrical appliances.





download code-here