Skip to main content
Post Closed as "Needs details or clarity" by brhans, ocrdu, devnull
added 81 characters in body
Source Link
ocrdu
  • 9.4k
  • 23
  • 33
  • 43

I am writing a program to control 3three DC motor levels and display speed (RPM) on a 7 segment-segment LED display using an 8051. UseI use an external interrupt to read pulse from encoder. When compiling, the program reports an error:

Only when I delete all the statements in forthe for loop void hienthi, the program does not report an error. Here

Here is the code:

#include <reg51.h> #include <stdio.h>   #define led1 P2^0 #define led2 P2^1 #define led3 P2^2 #define led4 P2^3 #define on 0 #define off 1   sbit pwm_out = P3^2; sbit low = P1^0; sbit medium = P1^1; sbit high = P1^2; sbit stop = P1^3; unsigned int count = 0,f f, t = 0; char so[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90}; // for number 0->9 void init() { TMOD = 0x10; pwm_out = 1; EX0 = 1; ET1 = 1; IT0 = 1; TR1 = 1; EA = 1; }   /*increments counter whenever falling edge is detected*/ void demxung() interrupt 0 { count++; }   void time() interrupt 3 { t++; TH1 = 0xfc; TL1 = 0x18; TR1 = 1; if (t>=1000) t >= 1000)  {   f = count;   count = 0;   t = 0;   } }   void hienthi (unsigned int dem) { unsigned char thousand, hundred, tens, unit; int i; thousand = dem/1000; hundred = (dem%1000)/100; tens = (dem%100)/10; unit = dem%10; for(i=0;i<20;i++)  (i=0; i<20; i++)  {   led1 = on; P0 = so[thousand]; delay_ms(100); led1 = off;   led2 = on; P0 = so[hundred]; delay_ms(100); led2 = off;   led3 = on; P0 = so[tens]; delay_ms(100); led3 = off;   led4 = on; P0 = so[unit]; delay_ms(100); led4 = off;   } }   void  delay_ms (unsigned int t) { unsigned int i,j ;j; for (i = 1; i <= ti=1; ;i<=t; i++) { for (j=1; j<125; j++); //delay_ms 1ms } }   void main() { pwm_out = 0; init(); while (1) {   if (low == 0) { medium = high = 1; low = 0; pwm_out = 1; delay_ms(30); pwm_out = 0; delay_ms(60); }   if (medium == 0) { low = high = 1; medium = 0; pwm_out = 1; delay_ms(50); pwm_out = 0; delay_ms(50); }   if (high == 0) { low = medium = 1; high = 0; pwm_out = 1; delay_ms(90); pwm_out = 0; delay_ms(10); }   if (stop == 0) {  low = medium = high = 1; pwm_out = 0; }   hienthi (f); } } 

I am writing a program to control 3 DC motor levels and display speed (RPM) on 7 segment LED using 8051. Use external interrupt to read pulse from encoder. When compiling, the program reports error

Only when delete all the statements in for loop void hienthi, the program does not report error. Here is code:

#include <reg51.h> #include <stdio.h> #define led1 P2^0 #define led2 P2^1 #define led3 P2^2 #define led4 P2^3 #define on 0 #define off 1 sbit pwm_out = P3^2; sbit low = P1^0; sbit medium = P1^1; sbit high = P1^2; sbit stop = P1^3; unsigned int count = 0,f ,t = 0; char so[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90}; // for number 0->9 void init() { TMOD = 0x10; pwm_out = 1; EX0 = 1; ET1 = 1; IT0 = 1; TR1 = 1; EA = 1; } /*increments counter whenever falling edge is detected*/ void demxung() interrupt 0 { count++; } void time() interrupt 3 { t++; TH1 = 0xfc; TL1 = 0x18; TR1 = 1; if (t>=1000)  {   f = count;   count = 0;   t = 0;   } } void hienthi (unsigned int dem) { unsigned char thousand, hundred, tens, unit; int i; thousand = dem/1000; hundred = (dem%1000)/100; tens = (dem%100)/10; unit = dem%10; for(i=0;i<20;i++)  {   led1 = on; P0 = so[thousand]; delay_ms(100); led1 = off;   led2 = on; P0 = so[hundred]; delay_ms(100); led2 = off;   led3 = on; P0 = so[tens]; delay_ms(100); led3 = off;   led4 = on; P0 = so[unit]; delay_ms(100); led4 = off;   } } void  delay_ms (unsigned int t) { unsigned int i,j ; for (i = 1; i <= t ; i++) { for (j=1; j<125; j++); //delay_ms 1ms } } void main() { pwm_out = 0; init(); while (1) { if (low == 0) { medium = high = 1; low = 0; pwm_out = 1; delay_ms(30); pwm_out = 0; delay_ms(60); } if (medium == 0) { low = high = 1; medium = 0; pwm_out = 1; delay_ms(50); pwm_out = 0; delay_ms(50); } if (high == 0) { low = medium = 1; high = 0; pwm_out = 1; delay_ms(90); pwm_out = 0; delay_ms(10); } if (stop == 0) { low = medium = high = 1; pwm_out = 0; } hienthi (f); } } 

I am writing a program to control three DC motor levels and display speed (RPM) on a 7-segment LED display using an 8051. I use an external interrupt to read pulse from encoder. When compiling, the program reports an error:

Only when I delete all the statements in the for loop void hienthi, the program does not report an error.

Here is the code:

#include <reg51.h> #include <stdio.h>   #define led1 P2^0 #define led2 P2^1 #define led3 P2^2 #define led4 P2^3 #define on 0 #define off 1   sbit pwm_out = P3^2; sbit low = P1^0; sbit medium = P1^1; sbit high = P1^2; sbit stop = P1^3; unsigned int count = 0, f, t = 0; char so[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90}; // for number 0->9 void init() { TMOD = 0x10; pwm_out = 1; EX0 = 1; ET1 = 1; IT0 = 1; TR1 = 1; EA = 1; }   /*increments counter whenever falling edge is detected*/ void demxung() interrupt 0 { count++; }   void time() interrupt 3 { t++; TH1 = 0xfc; TL1 = 0x18; TR1 = 1; if (t >= 1000)  { f = count; count = 0; t = 0; } }   void hienthi (unsigned int dem) { unsigned char thousand, hundred, tens, unit; int i; thousand = dem/1000; hundred = (dem%1000)/100; tens = (dem%100)/10; unit = dem%10; for (i=0; i<20; i++)  { led1 = on; P0 = so[thousand]; delay_ms(100); led1 = off; led2 = on; P0 = so[hundred]; delay_ms(100); led2 = off; led3 = on; P0 = so[tens]; delay_ms(100); led3 = off; led4 = on; P0 = so[unit]; delay_ms(100); led4 = off; } }   void delay_ms (unsigned int t) { unsigned int i,j; for (i=1; i<=t; i++) { for (j=1; j<125; j++); //delay_ms 1ms } }   void main() { pwm_out = 0; init(); while (1) {   if (low == 0) { medium = high = 1; low = 0; pwm_out = 1; delay_ms(30); pwm_out = 0; delay_ms(60); }   if (medium == 0) { low = high = 1; medium = 0; pwm_out = 1; delay_ms(50); pwm_out = 0; delay_ms(50); }   if (high == 0) { low = medium = 1; high = 0; pwm_out = 1; delay_ms(90); pwm_out = 0; delay_ms(10); }   if (stop == 0) {  low = medium = high = 1; pwm_out = 0; }   hienthi (f); } } 
added 177 characters in body
Source Link

HereError at row: led1 = on; P0 = so[thousand]; delay_ms(100); led1 = off;

Only when delete all the statements in for loop void hienthi, the program does not report error. Here is code:

Here is code:

Error at row: led1 = on; P0 = so[thousand]; delay_ms(100); led1 = off;

Only when delete all the statements in for loop void hienthi, the program does not report error. Here is code:

deleted 4 characters in body
Source Link
toolic
  • 10.9k
  • 11
  • 31
  • 35

I am writing a program to control 3 DC motor levels and display speed (RPM) on 7 segment LED using 8051. Use external interrupt to read pulse from encoder. When compiling, the program reports error C141: syntax error near '=', expected ';'.

C141: syntax error near '=', expected ';'.

Thank you!

I am writing a program to control 3 DC motor levels and display speed (RPM) on 7 segment LED using 8051. Use external interrupt to read pulse from encoder. When compiling, the program reports error C141: syntax error near '=', expected ';'.

Thank you!

I am writing a program to control 3 DC motor levels and display speed (RPM) on 7 segment LED using 8051. Use external interrupt to read pulse from encoder. When compiling, the program reports error

C141: syntax error near '=', expected ';'.

Source Link
Loading