>Here is the sample HiTECH C program I cannot get to work on the PIC16F877
>
>What am I doing wrong?
>Thanks
>Pete
>
>#include <pic.h>
>
>typedef unsigned char UINT8;
>typedef unsigned short UINT16;
>
>#define TIMER_PRESET 50
>
>/***************************************************************************
>***
> * Subroutines
>;***************************************************************************
>***/
>/*-----------------------------
>initalisation --------------------------------*/
>void init_pic(void)
> {
> // Configure TMR0 Port and interrupts
>
> TRISC = 0x0;
>
> T0CS = 0; // Timer increments on instruction clock
> T0IE = 1; // Enable interrupt on TMR0 overflow
> INTEDG = 1; // Rising edge trigger the interrupt
> INTE = 1; // enable the external interrupt RB0 change
> GIE = 1; // Global interrupt enable
> }
>
>/***************************************************************************
>***
> * Interrupt Service Routine
>
>****************************************************************************
>*/
>static void interrupt
>isr(void)
>{
>/*-------------------------- TMR0 timer
>interrupt ---------------------------*/
> if (T0IF) {
> TMR0 = TIMER_PRESET;
> T0IF = 0; // clear the interrupt flag
>
> }
>}
>/* ****************************** END ISR
>************************************/
>
>void main(void)
>{
> UINT8 counter=0;
> UINT16 counter1=0;
> init_pic();
>
>background_tasks:
>
> if ( counter1 == 0)
> {
> PORTC = counter;
> counter++;
> }
> counter1++;
>
> goto background_tasks;
>}
>
>///////////////////////////// END OF FILE
>////////////////////////////////////
>
>--
>
http://www.piclist.com hint: The list server can filter out subtopics
>(like ads or off topics) for you. See
http://www.piclist.com/#topics
>
>