AVR Int0 interrupt C language programming

Publisher:zeta16Latest update time:2016-08-06 Source: eefocusKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include

#define uchar unsigned char
#define uint unsigned int


uchar Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar Data[4]={0,7,2,8};
uchar Data1[4]={1,1,1,1};
void DelayMs(uint i) //0.25ms
{uchar j;
for(;i!=0;i--)
{for(j=250;j!=0;j--) {;}}
}

void Display(uchar *p) //间隔5ms显示
{uchar i,sel=0x01;
for(i=0;i<4;i++)
{PORTA=sel;
   PORTC=0xff-Table[p[i]];
   DelayMs(20);
   sel=sel<<1;
}
}

void main(void)
{uint i;
DDRA=0xff; //Set port A to input without pull-up;
PORTA=0xff;
DDRC=0xff; //Set port C to push-pull 1 output;
PORTC=0xff;
DDRD=0xff; //Set port D to pull-up input
PORTD=0xff;
PORTA=0xff;
PORTC=0x00;
DelayMs(10000);
MCUCR=0x00;//Falling edge
GIMSK=0x40;//int0
GIFR=0xff;
SREG=SREG|0x80;
while(1){Display(Da ta1);} /*{if((GIFR&0x40)==0x40) {GIFR=0xff;Display(Da ta);} else }*/ } #pragma interrupt_handler int0:2 void int0(void) {Display (Da ta1);}
/*{if((GIFR&0x40)==0x40) {GIFR=0xff;Display(Da ta);}
else 
}*/
} ta);}


Keywords:AVR Reference address:AVR Int0 interrupt C language programming

Previous article:ARM9 storage structure
Next article:AVR Eeprom C language programming

Recommended ReadingLatest update time:2024-11-16 22:47

AVR bit manipulation
1. Plan 1 1. #ifndef _M16_BIT_OPERATION_H_ #define _M16_BIT_OPERATION_H_ //Define a macro with parameters to replace the bit field structure for easy use #define BITFIELD(addr) (*((volatile bit_field *)(addr))) //Bit field definition structure typedef struct _bit_struct { unsigned Bit0:1; unsigned Bit1:1; unsign
[Microcontroller]
AVR-GCC program memory api
Program Memory If you want to put data (such as constants, strings, etc.) in FLASH, the user needs to specify the data type __ATTR_PROGMEM__. For ease of use, AVR-GCC defines some more intuitive symbols, as shown in the following table. 类型数据定义 typedef void PROGMEM  prog_void  typedef char PROGMEM  prog_char  type
[Microcontroller]
AVR IO port setting method detailed explanation
Seeing that many novices do not understand how to use AVR microcontroller bit variables, here is an I/O port bit operation method for everyone to learn: Here is the macro definition I use: #define LED_SET PORTD |= (1 PD5) //Position high #define LED_CLR PORTD &= ~(1 PD5) //position low #define LED_COM PORTD ^= (1 P
[Microcontroller]
AVR microcontroller serial port USART and PC communication example, explain the principle and procedure
"Parallel" communication: refers to the transmission of 8 bits of data through parallel lines at the same time. This greatly increases the data transmission speed, but the length of the parallel transmission line is limited. As the length increases, interference will increase, and data will be more prone to errors.
[Microcontroller]
AVR microcontroller serial port USART and PC communication example, explain the principle and procedure
Design of Intelligent Socket Energy Saving by AVR Microcontroller
0 Preface The standby energy consumption of computer peripheral devices (such as printers, scanners, speakers, etc.) not only increases consumers' daily electricity bills, but also causes great waste of electricity resources. The designed computer intelligent energy-saving socket uses the power on and off of the host
[Microcontroller]
Design of Intelligent Socket Energy Saving by AVR Microcontroller
Design of Universal Motor Control Device Based on AVR Microcontroller
0 Introduction The drive and control of motors is an important research topic in modern electronic technology. Different types of motors require different control and drive methods. Using a high-performance single-chip microcomputer as the core of the motor control drive device can effectively reduce the cost of
[Microcontroller]
Design of Universal Motor Control Device Based on AVR Microcontroller
[AVR] The length of various data when compiling with Gcc
When creating a project, select ATMEGA16 as the chip The lengths of various data types are as follows char 8 bits short 16 bits int 16 bits long 32 bits long long 64 bits Test the length of double and float when you have time.   Later, I discovered that gcc provides a header file stdint.h You can define new va
[Microcontroller]
Design of AVR single chip LED display screen with scrolling text and images
LED dot matrix blocks have the advantages of high brightness, uniform light emission, good reliability, and easy assembly, and can form display screens of various sizes. At present, LED display screens have been widely used in text display and have achieved good results, but most of them can only display scrolling tex
[Power Management]
Design of AVR single chip LED display screen with scrolling text and images
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号