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

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

15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
felicidaddinwoodie
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)
Mashood
 
The following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfThe following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdf
marketing413921
 
2011.02.18 marco parenzan - modelli di programmazione per le gpu
2011.02.18   marco parenzan - modelli di programmazione per le gpu2011.02.18   marco parenzan - modelli di programmazione per le gpu
2011.02.18 marco parenzan - modelli di programmazione per le gpu
Marco Parenzan
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
nikhil dixit
 
Survey_Paper
Survey_PaperSurvey_Paper
Survey_Paper
Abhra Koley
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filters
Jyotirmaya Mahanta
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
SANTIAGO PABLO ALBERTO
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
Ariel Tonatiuh Espindola
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - Introduction
Francis Seriña
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
Rodrigo Almeida
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
antiw
 
Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
Intel galileo gen 2
Intel galileo gen 2Intel galileo gen 2
Intel galileo gen 2
srknec
 
(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf
(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf
(15 points) TASK 2 Update Task 1 (You may use your IDE or Text Fil.pdf
archiespink
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
bishal bhattarai
 
ES-CH6.ppt
ES-CH6.pptES-CH6.ppt
ES-CH6.ppt
alaakaraja1
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
Miller Lee
 
QuecPython_Weather_Station_Demo_Tutorial.pdf
QuecPython_Weather_Station_Demo_Tutorial.pdfQuecPython_Weather_Station_Demo_Tutorial.pdf
QuecPython_Weather_Station_Demo_Tutorial.pdf
JohnEerl
 

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

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

More from VinaOconner450

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

More from VinaOconner450 (20)

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

Recently uploaded

Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 

Recently uploaded (20)

Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 

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; . . . . . . }