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;
                }
        }
}



Parents Reply Children
  • sorrey m8e,

    i canot do to much time on you.

    the error said u missed ; so u must put it in.

    i Think you copied the code bad?????!!!!!

    try controlc and controlv insted.

    Caveman

    try chaning the

  • "the error said u missed ; so u must put it in."

    No, the error said you missed ; Remember, this is your code. Plus you said in your first post "This example of coding technique is quite excelent from a professional point of view, I am sure of that !!."

    I think you are misrepresenting your code's level of excellence. Look at the simplified examples below. The first has none of your code and the second has only one the first line of your code.

    #include <reg52.h>
    
    void main(void)
    {
    }
    

    Builds successfully:

    Build target 'Target 1'
    linking...
    Program Size: data=9.0 xdata=0 code=16
    "sample82" - 0 Error(s), 0 Warning(s).
    

    Now, if I add only the very first line of your program, it breaks.

    #include <reg52.h>
    
    int16 isr_10m_your_delay;                   // this is a GLOBAL variable (16 bits), with a name given
    
    void main(void)
    {
    }
    
    Build target 'Target 1'
    compiling sample82.c...
    SAMPLE82.C(3): error C129: missing ';' before 'isr_10m_your_delay'
    Target not created
    

    YOUR CODE IS BROKEN. WHY?

  • Because the Keil forum is one of the most troll-infested I have ever seen - most probably because Keil do not require real accounts to post.

  • "Because the Keil forum is one of the most troll-infested I have ever seen ..."

    At the outset, the troll is enthusiastic:

    "I will try to be here more often for questions."
    "i Will Fix it For you."

    It turns out that the troll has no stamina:

    "i canot do to much time on you."