This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

master clock plaease

Using a compiler, (with this great site, no need to help you there).

Try this code for a process, just change the #include on line 1 for your device.

This example of coding technique is quite excelent from a professional point of view, I am sure of that !!.

Many comments within to explain, Please Read through the code. Do have fun with the knobs.

Hope your coding days will evolve as mine has through the years. I will try to be here more often for questions.

Caveman

PS. It worked in comepiled version.

int16 isr_10m_your_delay;                   // this is a GLOBAL variable (16 bits), with a name given

// The next line controls the timing
#define YOUR_10M_DELAY_TIME             100             // CHANGE FROM "100" to suit your needs.

// Here is the "reading" of many books part. ahh.. , I will leave that up to you, , The Powerful Interrupt

void ISR_TIMER0()using 5 as 2{

        set_timer0( 15535 );      // reload timer for 10 mS, just simple math.. pre-scaler setting and this count

        if (isr_10m_your_delay) isr_10m_your_delay --;   // decrement if NOT zero this time of the interrupt
}

void main(void) {
        setup_timer_0( RTC_INTERNAL | RTC_DIV_2 );  // get TMR0 initialized for the time base

        enable_interrupts( INT_TIMER0 );            // Allow the INT from TMR0
        enable_interrupts( EA );             // Allow Interrupts, without EA, never an Int at all

        // Initialize the delay
        isr_10m_your_delay = YOUR_10M_DELAY_TIME;
        for ( ;; ) {
                if ( isr_10m_your_delay == 0 ) {
                        // Pick your pin in the physical realm
                        output_toggle(PIN_P2.34);               // CHANGE ME FROM "PIN_B4"
                        // Re-Initialize the delay
                        isr_10m_your_delay = YOUR_10M_DELAY_TIME;
                }
        }
}



0