Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. How to write the program of single chip Microcomputer?

How to write the program of single chip Microcomputer?

Scheduled Pinned Locked Moved Hardware & Devices
htmlcomtutorialquestionlearning
4 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kimmy10
    wrote on last edited by
    #1

    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)

    Z V S 3 Replies Last reply
    0
    • K Kimmy10

      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)

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      What are you asking us?

      There are only 10 types of people in the world, those who understand binary and those who don't.

      1 Reply Last reply
      0
      • K Kimmy10

        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)

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • K Kimmy10

          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)

          S Offline
          S Offline
          Sarah Bishop
          wrote on last edited by
          #4

          I'm also not sure, maybe you should study more about C Programming, Processor Programming, Programming Controller. 192.168.1.1

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups