How to write the program of single chip Microcomputer?
-
Hi, In 89C51SND1C-UL digital tube selected, segment are used in P0 mouth. How to write a program. The datasheet of 89C51SND1C-UL is here http://www.kynix.com/Detail/1155480/89C51SND1C-UL.html This is a buzzer program.The bit-choice is in P2. I want to consult if I want to change bit-choice at P0 mouth, how to change the program. I convert P2 directly into P0 mouth. It doesn't work. I'm still learning single-chip computer.
="quote">
Quote:
#include #define uchar unsigned char #define uint unsigned int sbit speak=P3^4; sbit huang=P3^0; sbit red=P3^1; sbit sjia=P3^6; sbit sji=P3^7; sbit kai=P3^0; sbit fuwei=P3^1; sbit kais=P3^2; uchar num,temp,shijian,shi,ge,ashi,age,aa,tt,bb,i; uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90, 0x88,0x83,0xc6,0xa1,0x86,0x8e}; void delay(uint z) { uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void bj() { for(i=0;i<110;i++) { speak=~speak; delay(5); } for(i=0;i<230;i++) { speak=~speak; delay(2); } } void keyscan() { if(sjia==0) { delay(5); if(sjia==0) { shijian=shijian+1; if(shijian==99) { shijian=0; } } while(!sjia); } if(sji==0) { delay(5); if(sji==0) { shijian=shijian-1; if(shijian==0) { shijian=30; } } while(!sji); } } void zhuanhuan() { shi=shijian/10; ge=shijian%10; ashi=num/10; age=num%10; } void sound() { speak=0; } void main() { huang=0;red=0; EA=1; TMOD=0x11; T2CON=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=(65536-5000)/256; TL1=(65536-5000)%256; TH2=(65536-50000)/256; TL2=(65536-50000)%256; ET0=1; TR0=0; ET1=1; TR1=1; ET2=1; TR2=0; IT0=1; EX0=1; IT1=1; EX1=1; aa=0; bb=0; shijian=30; while(1) { keyscan(); } } void int_0() interrupt 0 { huang=1; TR0=1; TR2=1; } void timer_0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)
-
Hi, In 89C51SND1C-UL digital tube selected, segment are used in P0 mouth. How to write a program. The datasheet of 89C51SND1C-UL is here http://www.kynix.com/Detail/1155480/89C51SND1C-UL.html This is a buzzer program.The bit-choice is in P2. I want to consult if I want to change bit-choice at P0 mouth, how to change the program. I convert P2 directly into P0 mouth. It doesn't work. I'm still learning single-chip computer.
="quote">
Quote:
#include #define uchar unsigned char #define uint unsigned int sbit speak=P3^4; sbit huang=P3^0; sbit red=P3^1; sbit sjia=P3^6; sbit sji=P3^7; sbit kai=P3^0; sbit fuwei=P3^1; sbit kais=P3^2; uchar num,temp,shijian,shi,ge,ashi,age,aa,tt,bb,i; uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90, 0x88,0x83,0xc6,0xa1,0x86,0x8e}; void delay(uint z) { uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void bj() { for(i=0;i<110;i++) { speak=~speak; delay(5); } for(i=0;i<230;i++) { speak=~speak; delay(2); } } void keyscan() { if(sjia==0) { delay(5); if(sjia==0) { shijian=shijian+1; if(shijian==99) { shijian=0; } } while(!sjia); } if(sji==0) { delay(5); if(sji==0) { shijian=shijian-1; if(shijian==0) { shijian=30; } } while(!sji); } } void zhuanhuan() { shi=shijian/10; ge=shijian%10; ashi=num/10; age=num%10; } void sound() { speak=0; } void main() { huang=0;red=0; EA=1; TMOD=0x11; T2CON=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=(65536-5000)/256; TL1=(65536-5000)%256; TH2=(65536-50000)/256; TL2=(65536-50000)%256; ET0=1; TR0=0; ET1=1; TR1=1; ET2=1; TR2=0; IT0=1; EX0=1; IT1=1; EX1=1; aa=0; bb=0; shijian=30; while(1) { keyscan(); } } void int_0() interrupt 0 { huang=1; TR0=1; TR2=1; } void timer_0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)
-
Hi, In 89C51SND1C-UL digital tube selected, segment are used in P0 mouth. How to write a program. The datasheet of 89C51SND1C-UL is here http://www.kynix.com/Detail/1155480/89C51SND1C-UL.html This is a buzzer program.The bit-choice is in P2. I want to consult if I want to change bit-choice at P0 mouth, how to change the program. I convert P2 directly into P0 mouth. It doesn't work. I'm still learning single-chip computer.
="quote">
Quote:
#include #define uchar unsigned char #define uint unsigned int sbit speak=P3^4; sbit huang=P3^0; sbit red=P3^1; sbit sjia=P3^6; sbit sji=P3^7; sbit kai=P3^0; sbit fuwei=P3^1; sbit kais=P3^2; uchar num,temp,shijian,shi,ge,ashi,age,aa,tt,bb,i; uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90, 0x88,0x83,0xc6,0xa1,0x86,0x8e}; void delay(uint z) { uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void bj() { for(i=0;i<110;i++) { speak=~speak; delay(5); } for(i=0;i<230;i++) { speak=~speak; delay(2); } } void keyscan() { if(sjia==0) { delay(5); if(sjia==0) { shijian=shijian+1; if(shijian==99) { shijian=0; } } while(!sjia); } if(sji==0) { delay(5); if(sji==0) { shijian=shijian-1; if(shijian==0) { shijian=30; } } while(!sji); } } void zhuanhuan() { shi=shijian/10; ge=shijian%10; ashi=num/10; age=num%10; } void sound() { speak=0; } void main() { huang=0;red=0; EA=1; TMOD=0x11; T2CON=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=(65536-5000)/256; TL1=(65536-5000)%256; TH2=(65536-50000)/256; TL2=(65536-50000)%256; ET0=1; TR0=0; ET1=1; TR1=1; ET2=1; TR2=0; IT0=1; EX0=1; IT1=1; EX1=1; aa=0; bb=0; shijian=30; while(1) { keyscan(); } } void int_0() interrupt 0 { huang=1; TR0=1; TR2=1; } void timer_0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)
Few things on "how" Have a pseudoce about WHAT is the purpose of the code showing inputs / outputs. Than CHANGING the output would be more visible in code. Get into habit to comment your code. I do 80% comments and 20% real code ratio. I realize your construct your code using your native language that write it in English, so that is why there are no (English) comments in your code. Find a IDE which allows you to set breakpoints or use some other method to track your code. Good luck
-
Hi, In 89C51SND1C-UL digital tube selected, segment are used in P0 mouth. How to write a program. The datasheet of 89C51SND1C-UL is here http://www.kynix.com/Detail/1155480/89C51SND1C-UL.html This is a buzzer program.The bit-choice is in P2. I want to consult if I want to change bit-choice at P0 mouth, how to change the program. I convert P2 directly into P0 mouth. It doesn't work. I'm still learning single-chip computer.
="quote">
Quote:
#include #define uchar unsigned char #define uint unsigned int sbit speak=P3^4; sbit huang=P3^0; sbit red=P3^1; sbit sjia=P3^6; sbit sji=P3^7; sbit kai=P3^0; sbit fuwei=P3^1; sbit kais=P3^2; uchar num,temp,shijian,shi,ge,ashi,age,aa,tt,bb,i; uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90, 0x88,0x83,0xc6,0xa1,0x86,0x8e}; void delay(uint z) { uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void bj() { for(i=0;i<110;i++) { speak=~speak; delay(5); } for(i=0;i<230;i++) { speak=~speak; delay(2); } } void keyscan() { if(sjia==0) { delay(5); if(sjia==0) { shijian=shijian+1; if(shijian==99) { shijian=0; } } while(!sjia); } if(sji==0) { delay(5); if(sji==0) { shijian=shijian-1; if(shijian==0) { shijian=30; } } while(!sji); } } void zhuanhuan() { shi=shijian/10; ge=shijian%10; ashi=num/10; age=num%10; } void sound() { speak=0; } void main() { huang=0;red=0; EA=1; TMOD=0x11; T2CON=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=(65536-5000)/256; TL1=(65536-5000)%256; TH2=(65536-50000)/256; TL2=(65536-50000)%256; ET0=1; TR0=0; ET1=1; TR1=1; ET2=1; TR2=0; IT0=1; EX0=1; IT1=1; EX1=1; aa=0; bb=0; shijian=30; while(1) { keyscan(); } } void int_0() interrupt 0 { huang=1; TR0=1; TR2=1; } void timer_0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)
I'm also not sure, maybe you should study more about C Programming, Processor Programming, Programming Controller. 192.168.1.1