Vous êtes sur la page 1sur 3

Example 1:-7seg

This Example is a 0 9 counter displaying over 7segment display. Here am using 4 7segments for displaying the count. PORTB using for sending data and PORTA is using for selecting each 7seg. For make the PORTB as output put 0x00 to TRISB reg. similarly For make PORTA as output put 0x00 to TRISA. Then put corresponding numbers data (like 0x77 for Zero, 0x14 for one ..)to PORTB in a loop with delay in between every outing.

Example 2:-ADC
This Example is simple ADC program, for this input is taken from outside through PORTA0 and digital output is displaying in PORTC. In this program am using ADCON1 for result format selection and ADCON0 for ADC on, start conversion and checking of end of conversion. I can get the result in ADRESH-ADRESL register pair, that I will put to PORTC.

Example 3:-Blink
This program is a blinking of very ports (PORT A, B, C and D) with small delay. For make every port as output, am putting 0x00 to TRISA, B, C and D.

Example 4:-LCD
This example will display EI LABZ on LCD continuously. Here LCD is connected to PORTB, all data and control lines are taken from PORTB only. LCD is working in nibble Mode, So only 4 data lines are using. LCD needs 3 control lines(R/W, RS, and E) R/W am directly gnded in h/w because am only writing to LCD not reading from LCD. RS and E are also connected to PORTB. In the program there is two functions one is command and second is display. The command function will transfer command to LCD and display function will transfer data to LCD which is suppose to display.

Example 5:-LED_KEY
This is a simple interface between LEDS in PORTB with switches in PORTD. What ever switch pressed in PORTD corresponding LED in PORTB will glow.

Example 6:-PORT_BLINK
This Program is a blinking of higher and lower nibbles of PORTB alternatively with some delay. First I put 0x00 to TRISB for make PORTB as output, then I Put data to PORTB.

Example 7:-TIMER
This is a simple program to demonstrate how to use a timer0. Here am Blinking PORTB using delay from timer0. OPTION_REG is used to enable the timer0, TMR0 is the register for put timer count and INTCON is the register used to check the timer0 overflow. When TMR0 overflows from ff 00 then T0IF bit of INTCON will set.

Example 8:-TIMER1
This is a simple program to demonstrate how to use a timer1 (16 bit). Here am Blinking PORTB using delay from timer1 as same as previous example. T1CON is used to enable the timer1, TMR1H, TMR1HL are the registers for put timer count and PIR1 is the register used to check the timer1 overflow. When TMR1 overflows from ffff 0000 then TMR1IF bit of PIR1 will set.

Example 9:-TRX_UART
This program is for serial communication between PIC board and PC using HyperTerminal. Its a two way communication. What ever we entering from key board will send to PIC board and again send back to PC that will display on hyper terminal. Here am using 9600 baud rate, that I set using SPBRG register. TXSTA register is used to enable transmission. RCSTA register is used to enable reception. PIR1 register used to check Tx and Rx flags.

Example 10:-TX_UART
This program is for serial communication between PIC board and PC using HyperTerminal. Its a one way communication. Here am sending EI LABZ from PIC to PC that will display in HyperTerminal. Here also am using 9600 baud rate. So same setting for baud rate (SPBRG register) and Tx (TXSTA register) enable are doing here also.PIR1 used for flag checking.

Vous aimerez peut-être aussi