Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PIC12F675
- // 1Hz Time Base Osc.
- // Timer1 Module
- // 32.768 KHz
- unsigned short tick;
- void interrupt ()
- {
- if (PIR1.TMR1IF)
- {
- TMR1H = 0xE0;
- PIR1.TMR1IF = 0;
- tick = 1;
- }
- }
- void Init ()
- {
- TRISIO = 0;
- //Make all pins as output ports
- GPIO = 0;
- //Use Timer1 module
- INTCON.GIE = 1;
- INTCON.PEIE = 1;
- T1CON = 0x01;
- //Overflow every 8192
- TMR1H = 0xE0;
- TMR1L = 0x00;
- // Enable TMR1 interrupt
- PIE1.TMR1IE = 1;
- }
- void main ()
- {
- tick = 0;
- //Initialize Ports and Timer1 Module
- Init ();
- while (1)
- {
- if (tick)
- {
- tick = 0;
- GPIO = (1 << 0);
- }
- if (TMR1H > 0xF0)
- {
- GPIO = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement