Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===============================================================================
- Name : main.c
- Author :
- Version :
- Copyright : Copyright (C)
- Description : main definition
- ===============================================================================
- */
- #ifdef __USE_CMSIS
- #include "LPC17xx.h"
- #endif
- char leds[6]={0x04,0x10,0x20,0x40,0x02,0x08};//salidas para el display (e,d,c,a,b,f,g)
- void espera(void);
- void configPuertos(void);
- int n=0,i=5,ida=1,vuelta=0;
- int main(void) {
- configPuertos();
- LPC_GPIO0->FIOCLR|=(1<<0);
- while(1) {
- if (ida){
- LPC_GPIO2->FIOPIN=leds[n];
- espera();
- n++;
- }
- if (vuelta){
- LPC_GPIO2->FIOPIN=leds[i];
- espera();
- i--;
- }
- if(n>5){n=0;ida=0;vuelta=1;}
- if(i<0){i=5;ida=1;vuelta=0;}
- }
- return 0 ;
- }
- void espera(void)
- {
- asm ("ESPERA: MOV r0,#0x01000000 ");
- asm ("BUCLE: SUBS r0,r0,#1 ");
- asm (" BNE BUCLE ");
- }
- void configPuertos(void)
- {
- //*************Configuracion de pines***************************
- LPC_GPIO2->FIODIR0=0xFF;//los 8 bits menos significativos como salida
- LPC_GPIO0->FIODIR0=0x01;//ultimo bit menos significativo como salida
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement