Subversion Repositories group.electronics

Rev

Rev 132 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <string.h>
#include <util/delay.h>
#include <stdlib.h>

#include "config.h"
#include "avrutil.h"
#include "hc595.h"
#include "twires.h"


#ifndef NULL
#define NULL    ((void *)0)
#endif


void writeSegment(uint8_t digit, uint8_t value);
void pcInterrupt(void);
void receiveEvent(uint8_t bytes);

/* ------------------------------------------------------------------------- */



volatile uint8_t user_debug = 0;
volatile uint8_t tmr0_ovf = 0;

int main(void) {

  /*
  DDR : 1 = Output, 0 = Input
  PORT: 1 = Pullup for Input, otherwise set output
  PIN : Read input pin

        PB0     -
        PB1     -               - USB D- Low Speed
        PB2     -               - USB D+ 
        PB3     -               - SDA i2c bb
        PB4     -               - SCL i2c bb
        PB5     -
  */
  DDRB          = 0B00000000;
  PORTB         = 0B00000000;

    systime = 0;
    sysclockInit();

    wdt_enable(WDTO_1S);        // Watchdog for 1 sec
    sei();                      // Enable interrupts

    for(;;){
         wdt_reset();

        if (user_debug) {

        }

    }
    return 0;
}

ISR(TIM0_OVF_vect) {

        tmr0_ovf++;

        // Clk/1 TCCR0B = (1<< CS00);
        //20.0Mhz, 1ms = 78ovf
        //16.5Mhz, 1ms = 64ovf
        //16.0Mhz, 1ms = 62ovf
        //12.0Mhz, 1ms = 46ovf
        // 8.0Mhz, 1ms = 31ovf
        // 8.0Mhz, .5ms = 15ovf, 160r

        if (tmr0_ovf>=64) {
                        systime++;
                        tmr0_ovf = 0;
        }

}