본문 바로가기

전체 글

(88)
막대 저항 색상 코드 - Resistor Color Code
PIC 타이머0 인터럽트 서비스 루틴 + 키 입력 응용 #include #include #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF #define _XTAL_FREQ 4000000 #define sB_LED sGPIO.GP1#define sF_LED sGPIO.GP2#define BUTTON PORTBbits.RB3 volatile union { uint8_t port; struct { unsigned GP0 : 1; unsigned GP1 : 1; unsigned GP2 : 1; unsigned GP3 : 1; unsigned GP4 : 1; unsigned GP5 : 1; };} sGPIO; void main() { TRISB = 0x08; PORTB = 0; sGPIO.port = 0; ..
PIC 타이머0 인터럽트 서비스 루틴 다루기 #include #include #define _XTAL_FREQ 4000000 #define sF_LED sGPIO.GP2 #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF union { uint8_t port; struct { unsigned GP0 : 1; unsigned GP1 : 1; unsigned GP2 : 1; unsigned GP3 : 1; unsigned GP4 : 1; unsigned GP5 : 1; };} sGPIO; void main() { TRISB = 0x00; PORTB = 0; sGPIO.port = 0; OPTION_REGbits.T0CS = 0; OPTION_REGbits.PSA = 1; INTCONbits.T..
PIC 타이머0 외부 입력 카운터 모드 #include #include #define _XTAL_FREQ 4000000 #define sFLASH sGPIO.GP1 #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF union { uint8_t port; struct { unsigned GP0 : 1; unsigned GP1 : 1; unsigned GP2 : 1; unsigned GP3 : 1; unsigned GP4 : 1; unsigned GP5 : 1; };} sGPIO; void main() { TRISB = 0b00000100; OPTION_REGbits.T0CS = 1; OPTION_REGbits.PSA = 0; OPTION_REGbits.PS = 6; while(1) {..
PIC 타이머0 스위치 디바운싱 #include #include #define _XTAL_FREQ 4000000 #define sFLASH sGPIO.GP1 #define BUTTON PORTBbits.RB2 #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF union { uint8_t port; struct { unsigned GP0 : 1; unsigned GP1 : 1; unsigned GP2 : 1; unsigned GP3 : 1; unsigned GP4 : 1; unsigned GP5 : 1; };} sGPIO; void main() { TRISB = 0b00000100; PORTB = 0; sGPIO.port = 0; OPTION_REGbits.T0CS = 0; O..
PIC 타이머0 백그라운드 프로세스 타이밍 #include #include #define _XTAL_FREQ 4000000 #define sFLASH sGPIO.GP1#define sPRESS sGPIO.GP0 #define BUTTON PORTBbits.RB2 #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF union { uint8_t port; struct { unsigned GP0 : 1; unsigned GP1 : 1; unsigned GP2 : 1; unsigned GP3 : 1; unsigned GP4 : 1; unsigned GP5 : 1; };} sGPIO; void main() { uint8_t dc; TRISB = 0b00000100; PORTB = 0; sGPIO...
PIC 타이머0 를 활용한 버튼 빨리 누르기 게임 #include #include #define _XTAL_FREQ 4000000 #define START PORTBbits.RB1#define SUCCESS PORTBbits.RB0 #define BUTTON PORTBbits.RB2 #define MAXRT 200 #pragma config WDTE = OFF, PWRTE = OFF, CP = OFF, BOREN = OFF void main() { uint8_t cnt_8ms; TRISB = 0b00000100; OPTION_REGbits.T0CS = 0; OPTION_REGbits.PSA = 0; OPTION_REGbits.PS = 4; while(1) { PORTB = 0; __delay_ms(2000); START = 1; cnt_8ms = 0; ..
PIC 타이머0 레지스터 옵션