Пример #1
0
void main(void)
{
    WORD counter=0;

    SETCPUFREQ(CLK_12M);

    // enable timer 0 and timer 1 to be 16 bit counters
    TMOD = 0x11; 

    // enable timer 2 to also be a 16 bit counter
    T2CON = 0;
    RCAP2L = 0; // reload values for t2
    RCAP2H = 0; 

    EA=1; // enable interrupts
    ENABLE_TIMER0();
    ENABLE_TIMER1();
    ENABLE_TIMER2();
    TR0=1; // start t0
    TR1=1; // start t1 
    TR2=1; // start t2

    // and blink d5
    while (TRUE) {
        ++counter;
        if (!counter) {
            d5 = !d5;
            if (d5) { d5off(); } else { d5on(); }
        }
    }
}
Пример #2
0
void main(void)
{

    SETCPUFREQ(CLK_48M);

    // if this image is loaded to as iic to
    // the eeprom
    // the C2 bit will turn this on
    // turn it back off so the device can 
    // handle usb requests
    USBCS &= ~bmRENUM;

	EA=1; // enable interrupts

    sio0_init(57600);
    
	// timer 0 setup
	
	TL1=TH1=0; // start at 0
	ET1=1; // timer 1 interrupts
	TR1=1; // start timer 1
	
	
	d5off(); // end init
	
	while (1) {
		char r=getchar();
		putchar(r);
	}


}