bocon1903
22-12-2009, 05:06 PM
chương trình này em viết trên MikroC 8.2
void main() {
PORTA = 0; // Initialize PORTA
TRISA = 0; // Configure PORTA as output
PORTB = 0; // Initialize PORTB
TRISB = 0; // Configure PORTB as output
PORTC = 0; // Initialize PORTC
TRISC = 0; // Configure PORTC as output
PORTD = 0; // Initialize PORTD
TRISD = 0; // Configure PORTD as output
while(1) {
PORTA = ~PORTA; // toggle PORTA
Delay_ms(1000); // one second delay
PORTB = ~PORTB; // toggle PORTB
Delay_ms(1000); // one second delay
PORTC = ~PORTC; // toggle PORTC
Delay_ms(1000); // one second delay
PORTD = ~PORTD; // toggle PORTD
Delay_ms(1000); // one second delay
}
}
các port B,C,D của em đều chạy đúng,chỉ có mỗi port a chỉ chạy chân RA4,còn các RA khác không thay đổi(các port em nối với led). em mới học,có gì thiếu sót xin các anh chỉ giáo.em cám ơn
void main() {
PORTA = 0; // Initialize PORTA
TRISA = 0; // Configure PORTA as output
PORTB = 0; // Initialize PORTB
TRISB = 0; // Configure PORTB as output
PORTC = 0; // Initialize PORTC
TRISC = 0; // Configure PORTC as output
PORTD = 0; // Initialize PORTD
TRISD = 0; // Configure PORTD as output
while(1) {
PORTA = ~PORTA; // toggle PORTA
Delay_ms(1000); // one second delay
PORTB = ~PORTB; // toggle PORTB
Delay_ms(1000); // one second delay
PORTC = ~PORTC; // toggle PORTC
Delay_ms(1000); // one second delay
PORTD = ~PORTD; // toggle PORTD
Delay_ms(1000); // one second delay
}
}
các port B,C,D của em đều chạy đúng,chỉ có mỗi port a chỉ chạy chân RA4,còn các RA khác không thay đổi(các port em nối với led). em mới học,có gì thiếu sót xin các anh chỉ giáo.em cám ơn