Em mới học AVR , chưa hiểu được nhiều lệnh lắm, nhờ các anh giúp em hiểu nhưng câu lệnh sau nhé !
#include<mega16.h>
#include<delay.h>
unsigned char stepA[] = {0xFF,0xFE,0xFD,0xFB,0xF7},
stepB[] = {0xFF,0xEF,0xDF,0xBF,0x7F},
stepC[] = {0xFF,0xEF,0xDF,0xBF,0x7F};
unsigned char indexA,indexB,indexC;
unsigned char n_data;
unsigned char n_step=10;
unsigned int n_step3=5000,n_i;
void main(void)
{
PORTA=0xFF;
DDRA=oxFF;
PORTB=0xFF;
DDRB=oxFF;
PORTB=0xFF;
DDRB=oxFF;
PORTD=0xFF;
DDRD=oxFF;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
TIMSK=0x00;
ACSR=0x80;
SFIOR=0x00;
While (1)
{
if(indexA ++>3) indexA=1;
if(indexB ++>3) indexB=1;
if(indexC ++>3) indexC=1;
PORTA = stepA[indexA]&stepB[indexB];
PORTC = stepC[indexC];
delay_ms(500);
}}
#include<mega16.h>
#include<delay.h>
unsigned char stepA[] = {0xFF,0xFE,0xFD,0xFB,0xF7},
stepB[] = {0xFF,0xEF,0xDF,0xBF,0x7F},
stepC[] = {0xFF,0xEF,0xDF,0xBF,0x7F};
unsigned char indexA,indexB,indexC;
unsigned char n_data;
unsigned char n_step=10;
unsigned int n_step3=5000,n_i;
void main(void)
{
PORTA=0xFF;
DDRA=oxFF;
PORTB=0xFF;
DDRB=oxFF;
PORTB=0xFF;
DDRB=oxFF;
PORTD=0xFF;
DDRD=oxFF;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
TIMSK=0x00;
ACSR=0x80;
SFIOR=0x00;
While (1)
{
if(indexA ++>3) indexA=1;
if(indexB ++>3) indexB=1;
if(indexC ++>3) indexC=1;
PORTA = stepA[indexA]&stepB[indexB];
PORTC = stepC[indexC];
delay_ms(500);
}}
Comment