SlideShare a Scribd company logo
Lab #5_Revised (Due 12/13/15)
This is a revision on the previous Lab #5 assignment. The parts
revised are in bold.
The main program configures SysTick, the pushbutton and the
LCD panel, then puts itself in an infinite loop. The task is
divided into three parts.
a) Part A: Write a subroutine that beacons all LED at .2 second
interval all by itself. The lights flash for 0.1 second.
b) Part B: Write a subroutine that displaces a message on LCD
panel, "Red Alert! A tornado coming." when the pushbutton is
pressed.
c) Part C: Once Part A and Part C work, combine them together.
Instruction
1.
Do your work in Template-C, nothing else.
2.
The programming is done in C language only.
3.
Do not change the structure of the program. You may add or
remove any directives, but shouldn't change the structure itself.
4.
Add your work of programming to the bottom of the structure
where pause_1sec() ends.
5.
Once the program works properly in your Discovery kit, cut and
paste your work portion in .doc file and submit the work portion
only in BB without the main structure. (This is for grading
convenience.)
6.
Clearly put your name, section number and student ID at the
beginning of your file.
#include "stm32f30x_gpio.h"
#include "main.h"
GPIO_InitTypeDef GPIO_InitStructure;
RCC_ClocksTypeDef RCC_Clocks;
GPIO_InitTypeDef GPIO_InitStructure;
//
void init_systick(void); //function prototype
void init_pushbutton(void);
void init_LCD(void);
void init_GPIOE(void);
void IO_Init(void);
void EXTI0_Init(void);
void I2C2_init(void);
void LCD_write(int,int, char);
void LCD_clear(void);
void LCD_contrast(int); // Contrast level = 1..50
void LCD_backlight(int); // Backlight level = 1..8
void pause(void);
void pause_1sec(void);
char strDisp[20] ;
//volatile variables if any.
//static variables if any.
int main(void) {
IO_Init();
while(1);
}
/* Initialize I2C2 for LCD panel. */
void I2C2_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
I2C_InitTypeDef I2C_InitStructure;
RCC_I2CCLKConfig(RCC_I2C2CLK_SYSCLK);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2,
ENABLE);
I2C_DeInit(I2C2);
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_AnalogFilter =
I2C_AnalogFilter_Enable;
I2C_InitStructure.I2C_DigitalFilter = 0x00;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress =
I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_Timing = 0xC062121F;
//
I2C_Init(I2C2, &I2C_InitStructure);
I2C_Cmd(I2C2, ENABLE);
}
void LCD_write(int row, int col, char data) {
// Move to sepcified row, col
I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode,
I2C_Generate_Start_Write);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0xFE);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0x45);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) ==
RESET);
// if row == 0 else row asumed to be 1
if (!row) I2C_SendData(I2C2, col)
else I2C_SendData(I2C2, (0x40 + col));
I2C_TransferHandling(I2C2, 0x50 , 1, I2C_SoftEnd_Mode,
I2C_Generate_Start_Write);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) ==
RESET);
I2C_SendData(I2C2, data);
}
//
//
void LCD_contrast(int level) {
I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode,
I2C_Generate_Start_Write);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0xFE);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0x52);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, level);
pause();
}
//
//Set LCD Backlight - Level should be 1..8 (Seems to work best
if > 1)
//
void LCD_backlight(int level) {
I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode,
I2C_Generate_Start_Write);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0xFE);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0x53);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, level);
pause();
}
void LCD_clear() {
I2C_TransferHandling(I2C2, 0x50 , 2, I2C_SoftEnd_Mode,
I2C_Generate_Start_Write);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0xFE);
while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
I2C_SendData(I2C2, 0x51);
pause();
}
//
// this pause is for LCD only.
void pause(){
uint32_t i, time;
time=0x20000;
for (i=0; i
}
// Pause for 1 second.
void pause_1sec() {
uint32_t i, time;
time=0xA00000;
for (i=0; i
}
////////////////////////////////////////////////////////
/* Student's work start from here. */
/* EECE 237 F15 Lab5
*Name:
*Student ID:
*Class section number:
*Submit only this portion of the program to BB.
*/
void IO_Init(void){
//Configure and enable SysTick
init_systick();
//Configure and enable the push button and LCD panel
init_pushbutton();
init_GPIOE();
init_LCD();
// add as many lines as necessary
}
//Add other portions of the progrm.
// The end of student program.
----------------------------------------------------
Study the following programs.
void IO_Init() {
GPIOA_Init();
EXTI0_Init();
I2C2_init();
LCD_contrast(50);
LCD_backlight(8);
LCD_clear();
/* Get RCC clock frequency */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency/5);
//5 (=0.2sec) is the smallest number.
/* GPIOE Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE,
ENABLE);
/* Configure GPIOE for LED's */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 |
GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12| GPIO_Pin_11|
GPIO_Pin_10| GPIO_Pin_9| GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
}
void GPIOA_Init() {
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure PA0 pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
. . .
. . .
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,
ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9,
GPIO_AF_4);
. . .
. . .
//
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
/* Initialize EXTI0 for the blue button (GPIOA[0]).
* For this, configure SYSCFG and NVIC as well.
*/
void EXTI0_Init() {
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,
ENABLE);
/* Connect EXTI0 Line to PA0 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,
EXTI_PinSource0);
/* Configure EXTI0 line */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
. . .
. . .
}

More Related Content

RTF
Lcd n PIC16F
PDF
Functions for Nano 5 Card
TXT
PIC and LCD
PPT
Fundamentals.1
PPT
Microkernel Development
PDF
Digital Alarm Clock 446 project report
PPTX
pertemuan-keenam-lcd-display-project.pptx
PPTX
Building Hierarchy
Lcd n PIC16F
Functions for Nano 5 Card
PIC and LCD
Fundamentals.1
Microkernel Development
Digital Alarm Clock 446 project report
pertemuan-keenam-lcd-display-project.pptx
Building Hierarchy

Similar to Lab #5_Revised  (Due 121315)This is a revision on the previous.docx (20)

PDF
main.pdf java programming practice for programs
DOCX
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
PPTX
Micro c lab2(led patterns)
PDF
The following code is an implementation of the producer consumer pro.pdf
PPTX
2011.02.18 marco parenzan - modelli di programmazione per le gpu
DOCX
Dam gate open close lpc prog
PDF
Survey_Paper
PDF
Itsp documentation quadcopter flight controller based on kalman filters
PDF
Arduino: Arduino lcd
PDF
Switch Control and Time Delay - Keypad
PDF
Game Programming I - Introduction
PDF
Embedded systems development Defcon 19
PPT
Open Cv 2005 Q4 Tutorial
PPT
Operating System
PPTX
Intel galileo gen 2
PDF
(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf
PPTX
Embedded JavaScript
PPTX
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
PPT
ES-CH6.ppt
PDF
GPU Programming on CPU - Using C++AMP
main.pdf java programming practice for programs
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
Micro c lab2(led patterns)
The following code is an implementation of the producer consumer pro.pdf
2011.02.18 marco parenzan - modelli di programmazione per le gpu
Dam gate open close lpc prog
Survey_Paper
Itsp documentation quadcopter flight controller based on kalman filters
Arduino: Arduino lcd
Switch Control and Time Delay - Keypad
Game Programming I - Introduction
Embedded systems development Defcon 19
Open Cv 2005 Q4 Tutorial
Operating System
Intel galileo gen 2
(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf
Embedded JavaScript
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
ES-CH6.ppt
GPU Programming on CPU - Using C++AMP

More from VinaOconner450 (20)

DOCX
Learning SimulationSpecific information to consider for your desig.docx
DOCX
Learning Activity 1Identify key external forces Then interview.docx
DOCX
Learning ReflectionHow would you apply the four p’s to a service .docx
DOCX
Learning Activity #1Please discuss the ethical lessons that you le.docx
DOCX
Learning Activity Data on Child AbuseChildren are suffering from .docx
DOCX
Learning Activity #1Joe Jackson owned a sawmill in Stuttgart, Arka.docx
DOCX
Learning ModulesCh. 11 Corrections History and Institutions His.docx
DOCX
Learning goal To develop your ability to systematically analyze and.docx
DOCX
Learning Activity #1  What are the theoretical differences betw.docx
DOCX
LEADERSHIPImagine you are the HR, describe the role of a leade.docx
DOCX
Lead_Professor,Look forward to your quality work!Looking for.docx
DOCX
Leadership via vision is necessary for success. Discuss in detail .docx
DOCX
Learning Activity 1Impart your understanding and the organizati.docx
DOCX
Leadership versus Management Rost (1991) reinterpreted Burns mode.docx
DOCX
Laura Jackson discusses three spatial scales on the aspects of phy.docx
DOCX
Leadership Development and Succession PlanningAn effective success.docx
DOCX
Leadership FactorsWrite a four page paper (not including the tit.docx
DOCX
Leaders face many hurdles when leading in multiple countries. .docx
DOCX
Laws Enforcement TechnologiesIn this week’s assignment, you will e.docx
DOCX
Law Enforcement  Please respond to the followingIdentify the ke.docx
Learning SimulationSpecific information to consider for your desig.docx
Learning Activity 1Identify key external forces Then interview.docx
Learning ReflectionHow would you apply the four p’s to a service .docx
Learning Activity #1Please discuss the ethical lessons that you le.docx
Learning Activity Data on Child AbuseChildren are suffering from .docx
Learning Activity #1Joe Jackson owned a sawmill in Stuttgart, Arka.docx
Learning ModulesCh. 11 Corrections History and Institutions His.docx
Learning goal To develop your ability to systematically analyze and.docx
Learning Activity #1  What are the theoretical differences betw.docx
LEADERSHIPImagine you are the HR, describe the role of a leade.docx
Lead_Professor,Look forward to your quality work!Looking for.docx
Leadership via vision is necessary for success. Discuss in detail .docx
Learning Activity 1Impart your understanding and the organizati.docx
Leadership versus Management Rost (1991) reinterpreted Burns mode.docx
Laura Jackson discusses three spatial scales on the aspects of phy.docx
Leadership Development and Succession PlanningAn effective success.docx
Leadership FactorsWrite a four page paper (not including the tit.docx
Leaders face many hurdles when leading in multiple countries. .docx
Laws Enforcement TechnologiesIn this week’s assignment, you will e.docx
Law Enforcement  Please respond to the followingIdentify the ke.docx

Recently uploaded (20)

PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Updated Idioms and Phrasal Verbs in English subject
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Lesson notes of climatology university.
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Trump Administration's workforce development strategy
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial disease of the cardiovascular and lymphatic systems
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Updated Idioms and Phrasal Verbs in English subject
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Weekly quiz Compilation Jan -July 25.pdf
Lesson notes of climatology university.
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Trump Administration's workforce development strategy
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Chinmaya Tiranga quiz Grand Finale.pdf

Lab #5_Revised  (Due 121315)This is a revision on the previous.docx

  • 1. Lab #5_Revised (Due 12/13/15) This is a revision on the previous Lab #5 assignment. The parts revised are in bold. The main program configures SysTick, the pushbutton and the LCD panel, then puts itself in an infinite loop. The task is divided into three parts. a) Part A: Write a subroutine that beacons all LED at .2 second interval all by itself. The lights flash for 0.1 second. b) Part B: Write a subroutine that displaces a message on LCD panel, "Red Alert! A tornado coming." when the pushbutton is pressed. c) Part C: Once Part A and Part C work, combine them together. Instruction 1. Do your work in Template-C, nothing else. 2. The programming is done in C language only. 3. Do not change the structure of the program. You may add or remove any directives, but shouldn't change the structure itself. 4. Add your work of programming to the bottom of the structure where pause_1sec() ends. 5. Once the program works properly in your Discovery kit, cut and paste your work portion in .doc file and submit the work portion only in BB without the main structure. (This is for grading
  • 2. convenience.) 6. Clearly put your name, section number and student ID at the beginning of your file. #include "stm32f30x_gpio.h" #include "main.h" GPIO_InitTypeDef GPIO_InitStructure; RCC_ClocksTypeDef RCC_Clocks; GPIO_InitTypeDef GPIO_InitStructure; // void init_systick(void); //function prototype void init_pushbutton(void); void init_LCD(void); void init_GPIOE(void); void IO_Init(void); void EXTI0_Init(void); void I2C2_init(void); void LCD_write(int,int, char); void LCD_clear(void); void LCD_contrast(int); // Contrast level = 1..50 void LCD_backlight(int); // Backlight level = 1..8 void pause(void); void pause_1sec(void); char strDisp[20] ; //volatile variables if any. //static variables if any. int main(void) { IO_Init(); while(1);
  • 3. } /* Initialize I2C2 for LCD panel. */ void I2C2_init(void) { GPIO_InitTypeDef GPIO_InitStructure; I2C_InitTypeDef I2C_InitStructure; RCC_I2CCLKConfig(RCC_I2C2CLK_SYSCLK); RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE); I2C_DeInit(I2C2); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable; I2C_InitStructure.I2C_DigitalFilter = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_Timing = 0xC062121F; // I2C_Init(I2C2, &I2C_InitStructure); I2C_Cmd(I2C2, ENABLE); } void LCD_write(int row, int col, char data) { // Move to sepcified row, col I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0xFE); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0x45); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET);
  • 4. // if row == 0 else row asumed to be 1 if (!row) I2C_SendData(I2C2, col) else I2C_SendData(I2C2, (0x40 + col)); I2C_TransferHandling(I2C2, 0x50 , 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, data); } // // void LCD_contrast(int level) { I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0xFE); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0x52); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, level); pause(); } // //Set LCD Backlight - Level should be 1..8 (Seems to work best if > 1) // void LCD_backlight(int level) { I2C_TransferHandling(I2C2, 0x50 , 3, I2C_SoftEnd_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0xFE);
  • 5. while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0x53); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, level); pause(); } void LCD_clear() { I2C_TransferHandling(I2C2, 0x50 , 2, I2C_SoftEnd_Mode, I2C_Generate_Start_Write); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0xFE); while(I2C_GetFlagStatus(I2C2, I2C_ISR_TXIS) == RESET); I2C_SendData(I2C2, 0x51); pause(); } // // this pause is for LCD only. void pause(){ uint32_t i, time; time=0x20000; for (i=0; i } // Pause for 1 second. void pause_1sec() { uint32_t i, time; time=0xA00000; for (i=0; i } //////////////////////////////////////////////////////// /* Student's work start from here. */ /* EECE 237 F15 Lab5 *Name: *Student ID:
  • 6. *Class section number: *Submit only this portion of the program to BB. */ void IO_Init(void){ //Configure and enable SysTick init_systick(); //Configure and enable the push button and LCD panel init_pushbutton(); init_GPIOE(); init_LCD(); // add as many lines as necessary } //Add other portions of the progrm. // The end of student program. ---------------------------------------------------- Study the following programs. void IO_Init() { GPIOA_Init(); EXTI0_Init(); I2C2_init(); LCD_contrast(50); LCD_backlight(8); LCD_clear(); /* Get RCC clock frequency */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency/5); //5 (=0.2sec) is the smallest number.
  • 7. /* GPIOE Periph clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE); /* Configure GPIOE for LED's */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12| GPIO_Pin_11| GPIO_Pin_10| GPIO_Pin_9| GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; } void GPIOA_Init() { GPIO_InitTypeDef GPIO_InitStructure; /* Configure PA0 pin as input floating */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; . . . . . . RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_4); . . . . . . // GPIO_Init(GPIOA, &GPIO_InitStructure); } /* Initialize EXTI0 for the blue button (GPIOA[0]). * For this, configure SYSCFG and NVIC as well. */ void EXTI0_Init() { EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure;
  • 8. /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Connect EXTI0 Line to PA0 pin */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0); /* Configure EXTI0 line */ EXTI_InitStructure.EXTI_Line = EXTI_Line0; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; . . . . . . }