Tq2440 flow lamp Experiment

Source: Internet
Author: User

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!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.