EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Urgent need a solution for a Flow Chart

Urgent need a solution for a Flow Chart

|

Microcontroller › 8051 › Urgent need a solution for a Flow Chart

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 9 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 15, 2015 at 8:59 pm #3994
    yu cong gan
    Participant
     
     

    Hi guys~

    Can i know how tis code program flow chart look like? urgent for it~

    thanks for helping ^^

     D6 EQU 426 ; half-period for D6

    C6 EQU 478 ; half-period for C6
    E6 EQU 379 ; half-period for E6
    F6 EQU 358 ; half-period for F6 
    G6 EQU 319 ; half-period for G6
    A6 EQU 284 ; half-period for A6
    B6 EQU 253 ; half-period for B6
    C7 EQU 239 ; half-period for C7
     
    ORG 0000H
    MOV TMOD, #01H; CONIFIGURING TIMER TO  0
    MOV P1,#0FFH; CONFIGURE PORT 1 AS INPUT 
    CLR P2.0; SWITCH OFF BUZZER 
     
    CHOOSE: CALL PIANO; FUNCTION PIANO
    CALL GAME; FUNCTION GAME
    SJMP CHOOSE; JUMP BACK TO CHOOSE 
     
    PIANO: JB P1.0, GAME; CHECK GAME IF PIANO IS NOT PRESSED 
      JNB P1.0, $; CHECK GAME IF THE BUTTON IS RELEASED
      CLR  P0.0; COMPLEMENT LIGHT BULB 1  
      MOV A, #1; MOVE 1 TO THE ACCUMULATOR 
      CALL DELAY; DELAY FOR A SECOND
      CPL P0.0; CLEAR LIGHT BULB 1
      CALL PLAY_PIANO; CALL FUNCTION PLAY PIANO
     
    GAME: JB P1.1, PIANO; CHECK PIANO IF GAME IS NOT PRESSED 
    JNB P1.1, $; CHECK IF THE BUTTON IS RELEASED 
    CLR P0.1; COMPLEMENT LIGHT BULB 2 
    MOV A, #1; MOVE 1 INTO THE ACCUMULATOR 
    CALL DELAY; CALLE DELAY FOR A SECOND 
    CPL P0.1; CLEAR LIGHT BULB 2
    CALL PLAY_GAME; CALLL FUNCTION GAME 
    RET 
     
    PLAY_PIANO: CALL S1; CALL SWITCH 1 TO PLAY NOTE 1 
    CALL S2; CALL SWITCH 2 TO PLAY NOTE 2 
    CALL S3; CALL SWITHC 3 TO PLAY NOTE 3 
    CALL S4; CALL SWITCH 4 TO PLAY NOTE 4
    CALL S5; CALL SWITCH 5 TO PLAY NOTE 5
    CALL S6; CALL SWITCH 6 TO PLAY NOTE 6
    CALL S7; CALL SWTICH 7 TO PLAY NOTE 7
    CALL S8; CALL SWITCH 8 TO PLAY NOTE 8
    CALL S9; CALL SWITCH 9 TO END THE PIANO GAME
    SJMP S2;
     
     
    S1: JB P1.0, S2; JUMP TO SWITCH 2 IF SWITCH 1 IS NOT PRESSED
    JNB P1.0, $; WAIT FOR FINGER RELEASE 
    CALL PLAY_DO; PLAY DOH
    CLR P0.0
    MOV A, #1
    CALL DELAY
    SETB P0.0 
     
     
    S2: JB P1.1, S3; JUMP TO SWITCH 3 IF SWITCH 2 IS NOT PRESSED 
    JNB P1.1, $; WAIT FOR THE FINGER RELEASE 
    CALL PLAY_CO; PLAY CO
    CLR P0.1
    MOV A, #1
    CALL DELAY
    SETB P0.1 
     
    S3: JB P1.2, S4; JUMP TO SWITCH 4 IF SWITCH 3 IS NOT PRESSED 
    JNB P1.2,$; WAIT FOR THE FINGER RELEASE
    CALL PLAY_EO; PLAY EO
    CLR P0.2
    MOV A, #1
    CALL DELAY
    SETB P0.2 
     
    S4: JB P1.3, S5
    JNB P1.3,$
    CALL PLAY_FO;
    CLR P0.3
    MOV A, #1
    CALL DELAY
    SETB P0.3 
     
    S5: JB P1.4, S6
    JNB P1.4,$
    CALL PLAY_GO;
    CLR P0.4
    MOV A, #1
    CALL DELAY
    SETB P0.4 
     
    S6: JB P1.5, S7
    JNB P1.5,$
    CALL PLAY_AO;
    CLR P0.5
    MOV A, #1
    CALL DELAY
    SETB P0.5 
     
    S7: JB P1.6, S8
    JNB P1.6,$
    CALL PLAY_BO;
    CLR P0.6
    MOV A, #1
    CALL DELAY
    SETB P0.6 
     
    S8: JB P1.7, S1
    JNB P1.7,$
    CALL PLAY_CB;
    CLR P0.7
    MOV A, #1
    CALL DELAY
    SETB P0.7 
     
    S9: JB P3.0, S2
    JNB P3.0,$
     
     
     
     
    PLAY_GAME:  
    CALL GAME1;
    CALL GAME2; 
    CALL GAME3;
    CALL GAME4;
    RET 
     
    GAME1:
     CALL PLAY_DO;
     CLR P0.0; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.0; 
     
     CALL PLAY_CO;
     CLR P0.1
     MOV A, #5;
     CALL DELAY;  
     SETB P0.1;
     
     CALL PLAY_GO;
     CPL P0.4; 
     MOV A, #5
     CALL DELAY; 
     SETB P0.4;
     
     
     JB P1.0, $; 
     JNB P1.0, $; 
     CALL PLAY_DO;
     CLR P0.0; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.0;
     
     JB P1.1, $; 
     JNB P1.1, $; 
     CALL PLAY_CO;
     CLR P0.1; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.1; 
     
     JB P1.4, $; 
     JNB P1.4, $; 
     CALL PLAY_GO;
     CLR P0.4; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.4;
     
    RET
     
     
     
     
    GAME2:
     CALL PLAY_CO;
     CLR P0.1; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.1; 
     
     
     CALL PLAY_FO;
     CLR P0.3
     MOV A, #5;
     CALL DELAY;  
     SETB P0.3;
     
     CALL PLAY_AO;
     CLR P0.5; 
     MOV A, #5;
     CALL DELAY; 
     SETB P0.5;
     
     CALL PLAY_CB
     CLR P0.7; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.7;
     
     CALL PLAY_FO; 
     CLR P0.3; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.3; 
     
     
     JB P1.1, $; 
     JNB P1.1, $; 
     CALL PLAY_CO;
     CLR P0.1; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.1; 
     
     JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.3;
     
     JB P1.5, $; 
     JNB P1.5, $; 
     CALL PLAY_AO;
     CLR P0.5; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.5;
     
     JB P1.7, $; 
     JNB P1.7, $; 
     CALL PLAY_CB;
     CLR P0.7; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.7;
     
     JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #5; 
     CALL DELAY; 
     SETB P0.3;
    RET
     
    GAME3: 
     CALL PLAY_CO;
     CLR P0.1; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.1; 
     
     CALL PLAY_FO;
     CLR P0.3
     MOV A, #1;
     CALL DELAY;  
     SETB P0.3;
     
     CALL PLAY_AO;
     CPL P0.5; 
     MOV A, #1
     CALL DELAY; 
     SETB P0.5;
     
     CALL PLAY_CB;
     CPL P0.7; 
     MOV A, #1
     CALL DELAY; 
     SETB P0.7;
     
     CALL PLAY_FO;
     CPL P0.3; 
     MOV A, #1
     CALL DELAY; 
     SETB P0.3;
     
     CALL PLAY_DO;
     CPL P0.0; 
     MOV A, #1
     CALL DELAY; 
     SETB P0.0;
     
     CALL PLAY_GO;
     CPL P0.4; 
     MOV A, #1
     CALL DELAY; 
     SETB P0.4;
     
     
     JB P1.1, $; 
     JNB P1.1, $; 
     CALL PLAY_CO;
     CLR P0.1; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.1;
     
    JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.3; 
     
    JB P1.5, $; 
     JNB P1.5, $; 
     CALL PLAY_AO;
     CLR P0.5; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.5;
     
     JB P1.7, $; 
     JNB P1.7, $; 
     CALL PLAY_CB;
     CLR P0.7; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.7;
     
     JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.3;
     
     JB P1.0, $; 
     JNB P1.0, $; 
     CALL PLAY_DO;
     CLR P0.0; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.0;
     
     JB P1.4, $; 
     JNB P1.4, $; 
     CALL PLAY_GO;
     CLR P0.4; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.4;
     
    RET
     
     
    GAME4:  
     CALL PLAY_AO;
    CLR P0.5;
     MOV A, #1; 
     CALL DELAY;  
     SETB P0.5;
       
     CALL PLAY_GO;
     CLR P0.4; 
     MOV A, #1; 
     CALL DELAY;
     SETB P0.4;
     
    CLR P0.3;
    CALL PLAY_FO;
     MOV A, #1; 
     CALL DELAY; 
    SETB P0.3;
     
     
    CALL PLAY_EO;
    CLR P0.2;
     MOV A, #1; 
     CALL DELAY; 
    SETB P0.2;
     
     
    CALL PLAY_DO;
    CLR P0.0;
     MOV A, #1; 
     CALL DELAY;  
    SETB P0.0; 
     
     
    CALL PLAY_BO;
    CLR P0.6
     MOV A, #1; 
     CALL DELAY; 
    SETB P0.6
     
     
    CALL PLAY_FO;
    CLR P0.3
     MOV A, #1; 
     CALL DELAY;
    SETB P0.3
     
     
    CALL PLAY_CB;
    CLR P0.7
     MOV A, #1; 
     CALL DELAY; 
    SETB P0.7 
     
     
    JB P1.5, $; 
     JNB P1.5, $; 
     CALL PLAY_AO;
     CLR P0.5;
     MOV A, #1; 
     CALL DELAY;  
     SETB P0.5;
     
    JB P1.4, $; 
     JNB P1.4, $; 
     CALL PLAY_GO; 
     CLR P0.4
      MOV A, #1; 
     CALL DELAY;
     SETB P0.4;
     
    JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #1; 
     CALL DELAY;
     SETB P0.3;
     
     
    JB P1.2, $; 
     JNB P1.2, $; 
     CALL PLAY_EO;
     CLR P0.2; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.2;
     
     
    JB P1.0, $; 
     JNB P1.0, $; 
     CALL PLAY_DO;
     CLR P0.0;
      MOV A, #1; 
     CALL DELAY;
     SETB P0.0;
     
     
    JB P1.6, $; 
     JNB P1.6, $; 
     CALL PLAY_BO;
     CLR P0.6; 
     MOV A, #1; 
     CALL DELAY;
     SETB P0.6;
     
     
    JB P1.3, $; 
     JNB P1.3, $; 
     CALL PLAY_FO;
     CLR P0.3; 
     MOV A, #1; 
     CALL DELAY;
     SETB P0.3;
     
     
    JB P1.7, $; 
     JNB P1.7, $; 
     CALL PLAY_CB;
     CLR P0.7; 
     MOV A, #1; 
     CALL DELAY; 
     SETB P0.7;
     
    RET 
     
    PLAY_DO: ; subroutine to play DO6 (C6)
    MOV R1, #50 ; ad the no. of time L1 loop is repeated
    D1_L1: MOV R0, #21 ; he no. of time L2 loop is repeated
    D1_L2: MOV TH0, #HIGH(-426) ; load TH0 register from high byte address
    MOV TL0, #LOW(-426) ; load TL0 register from low byte address
    SETB TR0 ; start Timer 0
    JNB TF0, $ ; wait until Timer 0 overflows
    CLR TR0 ; stop Timer 0
    CLR TF0 ; clear Timer 0 overflow flag
    CPL P2.0 ; complement P2.0 for tone generation
    DJNZ R0, D1_L2 ; jump to D1_L2 until R1 is decreased to 0
    DJNZ R1, D1_L1 ; jump to D1_L1 until R2 is decreased to 0
    CLR P2.0 ; switch off buzzer
    RET ; exit subroutine 
     
    PLAY_CO: ; subroutine to play DO6 (C6)
    MOV R1, #50 ; ad the no. of time L1 loop is repeated
    C1_L1: MOV R0, #21 ; he no. of time L2 loop is repeated
    C1_L2: MOV TH0, #HIGH(-478) ; load TH0 register from high byte address
    MOV TL0, #LOW(-478) ; load TL0 register from low byte address
    SETB TR0 ; start Timer 0
    JNB TF0, $ ; wait until Timer 0 overflows
    CLR TR0 ; stop Timer 0
    CLR TF0 ; clear Timer 0 overflow flag
    CPL P2.0 ; complement P2.0 for tone generation
    DJNZ R0, C1_L2 ; jump to D1_L2 until R1 is decreased to 0
    DJNZ R1, C1_L1 ; jump to D1_L1 until R2 is decreased to 0
    CLR P2.0 ; switch off buzzer
    RET ; exit subroutine
     
    PLAY_EO: ; subroutine to play DO6 (C6)
    MOV R1, #50 ; ad the no. of time L1 loop is repeated
    E1_L1:MOV R0, #21 ; he no. of time L2 loop is repeated
    E1_L2: MOV TH0, #HIGH(-379) ; load TH0 register from high byte address
    MOV TL0, #LOW(-379) ; load TL0 register from low byte address
    SETB TR0 ; start Timer 0
    JNB TF0, $ ; wait until Timer 0 overflows
    CLR TR0 ; stop Timer 0
    CLR TF0 ; clear Timer 0 overflow flag
    CPL P2.0 ; complement P2.0 for tone generation
    DJNZ R0, E1_L2 ; jump to D1_L2 until R1 is decreased to 0
    DJNZ R1, E1_L1 ; jump to D1_L1 until R2 is decreased to 0
    CLR P2.0 ; switch off buzzer
    RET ; exit subroutine
     
    PLAY_FO: 
    MOV R1, #50
    F1_L1: MOV R0, #21
    F1_L2: MOV TH0, #HIGH(-358)
    MOV TL0, #LOW(-358)
    SETB TR0
    JNB TF0, $
    CLR TR0
    CLR TF0
    CPL P2.0
    DJNZ R0, F1_L2
    DJNZ R1, F1_L1
    CLR P2.0
    RET
     
    PLAY_GO: 
    MOV R1, #50
    G1_L1: MOV R0, #21
    G1_L2: MOV TH0, #HIGH(-319)
    MOV TL0, #LOW(-319)
    SETB TR0
    JNB TF0, $
    CLR TR0
    CLR TF0
    CPL P2.0
    DJNZ R0, G1_L2
    DJNZ R1, G1_L1
    CLR P2.0
    RET
     
    PLAY_AO: 
    MOV R1, #50
    A1_L1: MOV R0, #21
    A1_L2: MOV TH0, #HIGH(-284)
    MOV TL0, #LOW(-284)
    SETB TR0
    JNB TF0, $
    CLR TR0
    CLR TF0
    CPL P2.0
    DJNZ R0, A1_L2
    DJNZ R1, A1_L1
    CLR P2.0
    RET
     
    PLAY_BO: 
    MOV R1, #50
    B1_L1: MOV R0, #21
    B1_L2: MOV TH0, #HIGH(-253)
    MOV TL0, #LOW(-253)
    SETB TR0
    JNB TF0, $
    CLR TR0
    CLR TF0
    CPL P2.0
    DJNZ R0, B1_L2
    DJNZ R1, B1_L1
    CLR P2.0
    RET
     
    PLAY_CB: 
    MOV R1, #50
    Z1_L1: MOV R0, #21
    Z1_L2: MOV TH0, #HIGH(-239)
    MOV TL0, #LOW(-239)
    SETB TR0
    JNB TF0, $
    CLR TR0
    CLR TF0
    CPL P2.0
    DJNZ R0, Z1_L2
    DJNZ R1, Z1_L1
    CLR P2.0
    RET
     
    DELAY:
    MOV R3, A 
    RPT: MOV R2, #250 
    AGN: MOV R1, #250
    HERE: NOP
    NOP
    DJNZ R1, HERE
    DJNZ R2, AGN 
    DJNZ R3, RPT
    RET
     
     
      
    END
     
    September 19, 2015 at 7:10 pm #13304
    Ashutosh Bhatt
    Participant

    the program can be made from flow chart

    reverse process is very funny….

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Can I make two inputs from one?? June 21, 2025
  • Beats Solo 4 June 21, 2025
  • Behlke swich June 21, 2025
  • Is AI making embedded software developers more productive? June 21, 2025
  • Simple LED Analog Clock Idea June 21, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise