Sunday, January 10, 2016
Embedded Systems: Turn on LEDs with the push buttons of the MB90F387S MCU (Fujitsu Jouet Bleu Starter Kit)
Shinemax24
9:04 PM
Digital Systems Design
,
Embedded Systems
,
Fujitsu Jouet Bleu Starter Kit
,
MB90F387S MCU
No comments
:
In this program, we will make the integrated LEDs turn on and off upon the press of switches.
We will make LED1, LED3, and LED5 turn on when SW1 is pressed and make LED2, and LED3 turn on when SW2 is pressed. These LEDs turn off when the respective push buttons are released.
#include "_ffmc16.h"
#include "extern.h"
#include "monitor.h"
void main(void)
{
__set_il(7);
__EI();
IO_PDR1.byte=0x1F; //Set LEDs 1-5 to off
IO_DDR1.byte=0x1F; //Configure LEDs 1-5 as output
IO_DDR2.byte=0x00; //Configure SW1 and SW2 as input
while(1) //while system is on
{
if(IO_PDR2.bit.P25==1) //If SW1 is not pressed
{
IO_PDR1.bit.P10=1; //Turn off LED1
IO_PDR1.bit.P12=1; //Turn off LED3
IO_PDR1.bit.P14=1; //Turn off LED5
}
else //If SW1 is pressed
{
IO_PDR1.bit.P10=0; //Turn on LED1
IO_PDR1.bit.P12=0; //Turn on LED3
IO_PDR1.bit.P14=0; //Turn on LED5
}
if(IO_PDR2.bit.P27==1) //If SW2 is not pressed
{
IO_PDR1.bit.P11=1; //Turn off LED2
IO_PDR1.bit.P13=1; //Turn off LED4
}
else //If SW2 is pressed
{
IO_PDR1.bit.P11=0; //Turn on LED2
IO_PDR1.bit.P13=0; //Turn on LED4
}
}
}
/**************************************************************************************************
Interrupt Routine
**************************************************************************************************/
__interrupt void reload_int(void)
{
}
__interupt void ADC_int(void)
{
}
__interrupt void ext_int(void)
{
}
#pragma section INTVECT, locate=0xfffc00
#pragma intvect _start 0x8 0x0
#pragma intvect reload_int 17
#pragma intvect ADC_int 18
#pragma intvect ext_int 24
If you have any question, please, post a comment below.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment