Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <xc.h>
- #include <htc.h>
- #include <stdio.h>
- #pragma config WDTE=OFF, PWRTE=ON, MCLRE=OFF, CP=OFF, CPD=OFF, BOREN=OFF, IESO=OFF
- #define FOSC 8000000L
- unsigned int nsec, punon = 0, sinon = 0, vihon = 0;
- static void interrupt isr(void) // Keskeytyspalveluohjelma
- {
- if (T0IF) // ajastimen TIMER0 keskeytyslippu
- {
- TMR0 = 156;
- T0IF = 0;
- OPTION_REG = 0x00;
- if(nsec < 50 ) nsec++;
- else
- {
- nsec = 0;
- }
- if(nsec < punon) RB5 = 1;
- else RB5=0;
- if(nsec < vihon) RB6 = 1;
- else RB6 = 0;
- if(nsec < sinon) RB7 = 1;
- else RB7 = 0;
- }
- }
- void main(void)
- {
- OSCCON=0x77;
- int punled = 0;
- int sinled = 0;
- int vihled = 0;
- int tila = 1;
- unsigned int i = 0;
- ANSEL = 0;
- ANSELH = 0;
- TRISA = 0xFF;
- TRISB = 0x00;
- TRISC = 0x00;
- PORTA = 0x00;
- PORTB = 0x00;
- PORTC = 0x00;
- OSCTUNE=0x0F;
- OPTION_REG = 0x00;
- TMR0 = 156;
- T0IE = 1;
- GIE = 1;
- for (i = 0; i<60000; i++);
- while(1)
- {
- switch(tila)
- {
- case 1:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement