//Phần mô phỏng các bạn xem code rồi thiết kế nhé.
#include <xc.h>
#define _XTAL_FREQ 4000000
// CONFIG1
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
void choptat()
{
PORTEbits.RE2=0xFF;
__delay_ms(300);
PORTEbits.RE2=0x00;
__delay_ms(300);
}
void sangdan()
{
TRISD=0;
PORTD=0;
__delay_ms(100);
PORTD = 0x00;
__delay_ms(500);
for(int i=0;i<9;i++)
{
PORTD = PORTD << 1|0x01;
__delay_ms(300);
}
}
void main(void)
{
ANSEL=0x00;
ANSELH=0x00;
sangdan();
}
Blog trao đổi tài liệu học tập và làm việc. Thông tin hỗ trợ kĩ thuật phanhoangthinhhg@gmail.com
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Đăng ký:
Đăng Nhận xét (Atom)