Tutorial Microcontroller MCS-51 ATMEL ISP
 

 

Super MCS51 Trainer

Standart MCS51 Trainer

Standart AVR Trainer

Programmer USBASP

Standart ARM Trainer

 

1. Experiment Blink LED

In this experiment, we are going to turn ON and OFF led that connected to PORT IO microcontroller STM32F407. In this experiment, LED connected to PORTB12, PORTB13 and PORTB14. Coocox software are used to edit, to compile and to upload, in discovery board STM32F407. Dont forget to use 3.3V power suppply in schematic as shown in Fig 1. Standart library used in this experiment are CMIS library: STM32f4xx_gpio.h, STM32f4xx_rcc.h.


Fig.1. LED Schematic interface

Fig.2. CMIS Library for LED experiment

 

#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
unsigned char data;
void delay (int a);
void switchInit(void);
void ledInit(void);
void delay (int a)
{
           volatile int i,j;
           for (i=0 ; i < a ; i++)
           {
           j++;
           }
 return;
}

//
void ledInit(void)
{
           GPIO_InitTypeDef GPIO_InitStructure;
           RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
           GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14 ;
           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
           GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
           GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void switchInit(void)
{
           GPIO_InitTypeDef GPIO_InitStructure;
           RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
           GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6 ;
           GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
           GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
           GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
           GPIO_Init(GPIOE, &GPIO_InitStructure);
}
int main(void)
{
           ledInit();
           while (1)
           { // about 50ns per iteration
           GPIO_SetBits(GPIOB,GPIO_Pin_12);
           GPIO_SetBits(GPIOB,GPIO_Pin_13);
           GPIO_SetBits(GPIOB,GPIO_Pin_14);
           delay(100000);
           GPIO_ResetBits(GPIOB,GPIO_Pin_12);
           GPIO_ResetBits(GPIOB,GPIO_Pin_13);
           GPIO_ResetBits(GPIOB,GPIO_Pin_14);
           delay(100000);
           }
}