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

Syntax error in Timer0 interrupt routine

I am a hardware system/circuit designer attempting to utilize a c8051f330 MCU to save a bunch of hardware in the design of some special test equipment. In an attepmt to learn how to design and implement C code I am using some small test programs.

I have been unsuccesful in understanding and clearing a syntax error encountered in my attempt to program an interrupt service routine which uses the overflow of timer0 to generate interrupt 1. The section of the program listing whic has the error is:
69 void timer0_ISR (void) interrupt 1
70 {
71 1
72 1 LED = ~LED
73 1 }
*** ERROR C141 IN LINE 73 OF SPECIAL_FLASH_PROGRAM.C: syntax error near '}'
74
75/*------------End of ALL STUFF---------------------*/

Thanks in advance for your help!! It's greatly appreciated.

Dennis

Parents
  • Eric,

    I tried a semicolon at the end of the interrupt statement. The effect was to create a bunch more errors, associated with that statement. I've removed the semicolon.

    Why do you suppose that the error that I'm seeing is associated with the "end" brace of the statement? Does this mean that something is missing either before or after the brace?

Reply
  • Eric,

    I tried a semicolon at the end of the interrupt statement. The effect was to create a bunch more errors, associated with that statement. I've removed the semicolon.

    Why do you suppose that the error that I'm seeing is associated with the "end" brace of the statement? Does this mean that something is missing either before or after the brace?

Children
  • void timer0_ISR (void) interrupt 1
    {
       LED = ~LED;
    }
    

    That is where it belongs.
    You are going to need a C reference Book.
    All C statments end with a semicolon.

  • 69 void timer0_ISR (void) interrupt 1
    70 {
    71 1
    72 1    LED = ~LED
    73 1 }
    *** ERROR C141 IN LINE 73 OF SPECIAL_FLASH_PROGRAM.C: syntax error near '}'

    "Why do you suppose that the error that I'm seeing is associated with the 'end' brace of the statement?"

    Because the syntax is fine up to that point!

    At that point, the compiler knows that it's on the right-hand side of an assignment, and it knows what things are valid there - and a closing brace is not one of them!