1. This code is a clock code designed for the timer T0 programming of 89C52 single-chip microcomputer.
#include<reg52.h>
unsigned char code ledcode[]={0x3f,0x5b,0x4f,0x66,0x7d,7,0x7f,0x6f}; //Segment selection code for common cathode 0-9
unsigned char data hou,min,sec,num,disbuf[]={0,0,10,0,0,0,10,0,0}; //hour,minute,sec,num is the number of T0 interrupts,disbuf is the number of displayed digits
#define codport P0; //Display segment output port
#define sitport P2; //Display bit code output port
void display() //display function
{
unsigned int j; //for loop
unsigned char i,scan; //scan is the bit code of the output control display bit, also called scan code
scan=0x01;
for(i=0;i<6;i++)
{
codport=0; //Display new content before clearing the screen, otherwise it will be displayed incorrectly in Proteus
codport=ledcode[disbuf[i]]; //the number to be displayed send break code port
sitport=~scan; //Bit code port low corresponding bit valid, lit
scan=(scan<<1);
for(j=0;j<500;j++);
}
}
2、In the following program, the compilation shows an error
clock.c(14): warning C275: expression with possibly no effect
clock.c(14): error C141: syntax error near ‘=’, expected ‘__asm’
clock.c(15): error C141: syntax error near ‘=’, expected ‘__asm’
clock.c(16): error C141: syntax error near ‘=’, expected ‘__asm’
clock.c – 3 Error(s), 1 Warning(s).
Locating the error found is
codport=0; //clear the screen before displaying new content, otherwise it will be displayed incorrectly in Proteus
codport=ledcode[disbuf[i]]; //the number to be displayed is sent to the code breaking port
sitport=~scan; //Bit code port low corresponding bit valid, lit
3. Since bit operations are required for codport and sitport, the modified macro is defined as
#include<reg52.h>
unsigned char code ledcode[]={0x3f,0x5b,0x4f,0x66,0x7d,7,0x7f,0x6f}; //Segment selection code for common cathode 0-9
unsigned char data hou,min,sec,num,disbuf[]={0,0,10,0,0,0,10,0,0}; //hour,minute,sec,num is the number of T0 interrupts,disbuf is the number of displayed digits
sibt codport=P0; //display segment code output port
sbit sitport=P2; //display bit code output port
4. Compiled successfully after modification
Read More:
- [Solved] KEIL Error: keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘
- [Solved] Error 4 opening dom ASM/Self in 0x8283c00
- [Solved] error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
- [Solved] fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler
- Keil5 error: #29: expected an expression [Solved]
- C++:error C2872: ‘byte‘: ambiguous symbol [How to Solve]
- C++ clang Compile Error: error: expected unqualified-id
- [Solved] Error c2226: syntax error: unexpected ‘lpstr’ type
- How to Solve Keil Error: error: #29: expected an expression
- How to Solve Fatal error stdatomic in C/C++ Compilation
- Grpc Compilation issues: “C++ versions less than C++11 are not supported.
- [Solved] winnt.h a large number of file errors (287): error c2059: syntax error: “;”
- Cmake Setting Support C++11 This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options
- bazel Compile Error: absl/base/policy_checks.h:79:2: error: #error “C++ versions less than C++14 are not supported.”
- [Solved] URIError: Failed to decode param ‘/%3C%=%20BASE_URL%20%3Estatic/index.%3C%=%20VUE_APP_INDEX_CSS_HASH%20%3E.css’
- Cannot start container 39f96c64a9c6: [8] System error: exec format error
- Keil Error: error:#130:expected a “{” [How to Solve]
- [Solved] error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools“
- [Solved] Error: error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
- keil: ERROR L107:ADDRESS SPACE OVERFlOW [How to Solve]