All pastes #2060156 Raw Edit

Untitled

public text v1 · immutable
#2060156 ·published 2011-05-15 12:06 UTC
rendered paste body
#include <pic.h>
#include <htc.h>
#include "system.h"

#define _XTAL_FREQ		4000000

void interrupt ISR( void ){	
	if(T0IF){ // Every 1ms
		T0IF = 0;
		TMR0 = 6;
		system_tick();
	}
}

void timerSetup( void ){
OSCF = 1; // 4Mhz internal clock

// Timer0 Registers: 
// Prescaler=1:4; TMR0 Preset=6; Freq=1.000,00Hz; Period=1,00 ms
OPTION = 0b00000011;
TMR0 = 6;           // preset for timer register
T0IE = 1;
GIE = 1;
}

void ioSetup(){
	TRISA = 0x00;
	TRISB = 0x00;
	PORTA = 0xFF;
	PORTB = 0xFF;
}

void main( void ){
	ioSetup();
	timerSetup();
	for(;;){
		system_scheduler();
	}
}