IO Ports PIC IO Port Digital IO Ports

  • Slides: 20
Download presentation

I/O Ports • PIC ม I/O Port ชนดตางๆเพอใชตดตอก บอปกรณตอพวงผาน เชน • Digital I/O Ports

I/O Ports • PIC ม I/O Port ชนดตางๆเพอใชตดตอก บอปกรณตอพวงผาน เชน • Digital I/O Ports • Analog to Digital Converter Port • Pulse Width Modulation (PWM) Ports

I/O Port ของ PIC 18 F 8722 PWR = Power Supply O = Output

I/O Port ของ PIC 18 F 8722 PWR = Power Supply O = Output I = Input ANA = Analog Signal DIG = Digital Output ST = Schmitt Buffer Input • TTL = TTL Buffer Input • X = Don’t Care • • •

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

I/O Port ของ PIC 18 F 8722

#include <p 18 f 8722. h> #include <adc. h> #include <delays. h> #include <timers.

#include <p 18 f 8722. h> #include <adc. h> #include <delays. h> #include <timers. h> ADCON 1 = 0 b 00001110; TRISAbits. TRISA 5 = 1; TRISBbits. TRISB 0 = 1; TRISD = 0; PORTD = 1; #define NUMBER_OF_LEDS 8 while(1) { #pragma code void main(void) { char LED[] = { }; int i=0; if(PORTAbits. RA 5==0) { i++; if(i==8) i=7; PORTD = LED[i]; while(PORTAbits. RA 5==0); } 0 b 00000001, 0 b 00000011, 0 b 00000111, 0 b 00001111, 0 b 00011111, 0 b 00111111, 0 b 01111111, 0 b 1111 if(PORTBbits. RB 0==0) { i--; if(i<0) i=0; PORTD = LED[i]; while(PORTBbits. RB 0==0); } } }

#include <p 18 f 8722. h> #include <adc. h> #include <delays. h> #include <timers.

#include <p 18 f 8722. h> #include <adc. h> #include <delays. h> #include <timers. h> ADCON 1 = 0 b 00001110; TRISAbits. TRISA 5 = 1; TRISBbits. TRISB 0 = 1; TRISD = 0; PORTD = 1; #define NUMBER_OF_LEDS 8 while(1) { #pragma code void main(void) { char LED[] = { }; int i=0; if(PORTAbits. RA 5==0) { i++; if(i==8) i=7; PORTD = LED[i]; while(PORTAbits. RA 5==0); } 0 b 00000001, 0 b 00000011, 0 b 00000111, 0 b 00001111, 0 b 00011111, 0 b 00111111, 0 b 01111111, 0 b 1111 if(PORTBbits. RB 0==0) { i--; if(i<0) i=0; PORTD = LED[i]; while(PORTBbits. RB 0==0); } } }