1. Check the circuit diagram of the core board and find that the four LEDs are connected to gpb5 and ~ Gpb8 with four pins allows the four pins to output low levels in turn to realize the flow lamp.
2. Create a project ledtest. MCP
The project requires some basic procedures for the board. If you don't understand it, you don't have to worry about it. You just need to add these programs to the project.
3. Program for LED Lighting
Main. c
#include"led.h"int Main(){Led_Init();while(1){Led_On();}return 0;}
Led. c
# Include "led. H" # include "2440addr. H" # include "common. H" Void led_init (void) {rgpbcon & = ~ (3 <10 | 3 <12 | 3 <14 | 3 <16 ); rgpbcon | = (1 <10 | 1 <12 | 1 <14 | 1 <16); // set the GPB port to 5th ~ 8 pin is set to output rgpbup & = ~ (1 <5 | 1 <6 | 1 <7 | 1 <8 ); // cancel the pull-up resistor rgpbdat | = (1 <5 | 1 <6 | 1 <7 | 1 <8); // 5 ~ 8-pin output high, turn off led} void led_on (void) {int I, K = 0 xfff; K & = ~ (1 <5); for (I = 0; I <4; I ++) {rgpbdat = K; delay (); k = (k <1 );}}
Led. h
#ifndef_LED_H_#define_LED_H_extern void Led_Init(void);extern void Led_On(void);#endif
Common. h
#ifndef_COMMON_H_#define_COMMON_H_extern void Delay(void);#endif
Common. c sequential light delay Program
#include"common.h"void Delay(void){int i;for(i=0;i<1000000;i++);}
You can use the fl lamp function during the test!