Dear all iam girgis adly in 4th year electrical faculty of engineer I try to write a program for pic18f452 firing the mosfets of the multilevel inverter at a certain time by a certain sequence and the frequency of the output equal 50 HZ I write the program using (microC) language
void main()
{
TRISB=0;
LOOP:
PORTB=0;
delay_ms(.3355);
PORTB=0B00100110;
delay_ms(2.717);
PORTB=0B00100101;
delay_ms(3.889);
PORTB=0B00100110;
delay_ms(2.667);
PORTB=0;
delay_ms(0.777);
PORTB=0B00011010;
delay_ms(2.667);
PORTB=0B00011001;
delay_ms(3.889);
PORTB=0B00011010;
delay_ms(2.667);
PORTB=0;
delay_ms(0.388);
goto loop;
}
but the compiler found this errors
Internal error line 8
';'expected but delay_ms is found line7
Integral constant expected line6
Syntax error :expected ')'but found ';' line7
I don’t know how to re write the program without errors and without changing the time it will be grateful if any one help me
Dear all iam girgis adly in 4th year electrical faculty of engineer I try to write a program for pic18f452 firing the mosfets of the multilevel inverter at a certain time by a certain sequence and the frequency of the output equal 50 HZ I write the program using (microC) language
void main()
{
TRISB=0;
LOOP:
PORTB=0;
delay_ms(.3355);
PORTB=0B00100110;
delay_ms(2.717);
PORTB=0B00100101;
delay_ms(3.889);
PORTB=0B00100110;
delay_ms(2.667);
PORTB=0;
delay_ms(0.777);
PORTB=0B00011010;
delay_ms(2.667);
PORTB=0B00011001;
delay_ms(3.889);
PORTB=0B00011010;
delay_ms(2.667);
PORTB=0;
delay_ms(0.388);
goto loop;
}
but the compiler found this errors
Internal error line 8
';'expected but delay_ms is found line7
Integral constant expected line6
Syntax error :expected ')'but found ';' line7
I don’t know how to re write the program without errors and without changing the time it will be grateful if any one help me
However, I think you have to pass an integer to the mikroC function 'delay_mS'. If you need to wait for fractions of a ms, you could use the function 'delay_us'.
Delaying fractions of a us can be done including NOP's, if the PIC is running at high frequency (f>4 MHz) but the delay must be an integer multiple of 4/f.
To generate precise delays you should check the assembly code generated by your compiler and do simulations with breakpoints.