Microcontroller › 8051 › Urgent need a solution for a Flow Chart
- This topic has 1 reply, 2 voices, and was last updated 8 years, 12 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
September 15, 2015 at 8:59 pm #3994yu cong ganParticipant
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 C6E6 EQU 379 ; half-period for E6F6 EQU 358 ; half-period for F6G6 EQU 319 ; half-period for G6A6 EQU 284 ; half-period for A6B6 EQU 253 ; half-period for B6C7 EQU 239 ; half-period for C7ORG 0000HMOV TMOD, #01H; CONIFIGURING TIMER TO 0MOV P1,#0FFH; CONFIGURE PORT 1 AS INPUTCLR P2.0; SWITCH OFF BUZZERCHOOSE: CALL PIANO; FUNCTION PIANOCALL GAME; FUNCTION GAMESJMP CHOOSE; JUMP BACK TO CHOOSEPIANO: JB P1.0, GAME; CHECK GAME IF PIANO IS NOT PRESSEDJNB P1.0, $; CHECK GAME IF THE BUTTON IS RELEASEDCLR P0.0; COMPLEMENT LIGHT BULB 1MOV A, #1; MOVE 1 TO THE ACCUMULATORCALL DELAY; DELAY FOR A SECONDCPL P0.0; CLEAR LIGHT BULB 1CALL PLAY_PIANO; CALL FUNCTION PLAY PIANOGAME: JB P1.1, PIANO; CHECK PIANO IF GAME IS NOT PRESSEDJNB P1.1, $; CHECK IF THE BUTTON IS RELEASEDCLR P0.1; COMPLEMENT LIGHT BULB 2MOV A, #1; MOVE 1 INTO THE ACCUMULATORCALL DELAY; CALLE DELAY FOR A SECONDCPL P0.1; CLEAR LIGHT BULB 2CALL PLAY_GAME; CALLL FUNCTION GAMERETPLAY_PIANO: CALL S1; CALL SWITCH 1 TO PLAY NOTE 1CALL S2; CALL SWITCH 2 TO PLAY NOTE 2CALL S3; CALL SWITHC 3 TO PLAY NOTE 3CALL S4; CALL SWITCH 4 TO PLAY NOTE 4CALL S5; CALL SWITCH 5 TO PLAY NOTE 5CALL S6; CALL SWITCH 6 TO PLAY NOTE 6CALL S7; CALL SWTICH 7 TO PLAY NOTE 7CALL S8; CALL SWITCH 8 TO PLAY NOTE 8CALL S9; CALL SWITCH 9 TO END THE PIANO GAMESJMP S2;S1: JB P1.0, S2; JUMP TO SWITCH 2 IF SWITCH 1 IS NOT PRESSEDJNB P1.0, $; WAIT FOR FINGER RELEASECALL PLAY_DO; PLAY DOHCLR P0.0MOV A, #1CALL DELAYSETB P0.0S2: JB P1.1, S3; JUMP TO SWITCH 3 IF SWITCH 2 IS NOT PRESSEDJNB P1.1, $; WAIT FOR THE FINGER RELEASECALL PLAY_CO; PLAY COCLR P0.1MOV A, #1CALL DELAYSETB P0.1S3: JB P1.2, S4; JUMP TO SWITCH 4 IF SWITCH 3 IS NOT PRESSEDJNB P1.2,$; WAIT FOR THE FINGER RELEASECALL PLAY_EO; PLAY EOCLR P0.2MOV A, #1CALL DELAYSETB P0.2S4: JB P1.3, S5JNB P1.3,$CALL PLAY_FO;CLR P0.3MOV A, #1CALL DELAYSETB P0.3S5: JB P1.4, S6JNB P1.4,$CALL PLAY_GO;CLR P0.4MOV A, #1CALL DELAYSETB P0.4S6: JB P1.5, S7JNB P1.5,$CALL PLAY_AO;CLR P0.5MOV A, #1CALL DELAYSETB P0.5S7: JB P1.6, S8JNB P1.6,$CALL PLAY_BO;CLR P0.6MOV A, #1CALL DELAYSETB P0.6S8: JB P1.7, S1JNB P1.7,$CALL PLAY_CB;CLR P0.7MOV A, #1CALL DELAYSETB P0.7S9: JB P3.0, S2JNB P3.0,$PLAY_GAME:CALL GAME1;CALL GAME2;CALL GAME3;CALL GAME4;RETGAME1:CALL PLAY_DO;CLR P0.0;MOV A, #5;CALL DELAY;SETB P0.0;CALL PLAY_CO;CLR P0.1MOV A, #5;CALL DELAY;SETB P0.1;CALL PLAY_GO;CPL P0.4;MOV A, #5CALL 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;RETGAME2:CALL PLAY_CO;CLR P0.1;MOV A, #5;CALL DELAY;SETB P0.1;CALL PLAY_FO;CLR P0.3MOV A, #5;CALL DELAY;SETB P0.3;CALL PLAY_AO;CLR P0.5;MOV A, #5;CALL DELAY;SETB P0.5;CALL PLAY_CBCLR 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;RETGAME3:CALL PLAY_CO;CLR P0.1;MOV A, #1;CALL DELAY;SETB P0.1;CALL PLAY_FO;CLR P0.3MOV A, #1;CALL DELAY;SETB P0.3;CALL PLAY_AO;CPL P0.5;MOV A, #1CALL DELAY;SETB P0.5;CALL PLAY_CB;CPL P0.7;MOV A, #1CALL DELAY;SETB P0.7;CALL PLAY_FO;CPL P0.3;MOV A, #1CALL DELAY;SETB P0.3;CALL PLAY_DO;CPL P0.0;MOV A, #1CALL DELAY;SETB P0.0;CALL PLAY_GO;CPL P0.4;MOV A, #1CALL 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;RETGAME4: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.6MOV A, #1;CALL DELAY;SETB P0.6CALL PLAY_FO;CLR P0.3MOV A, #1;CALL DELAY;SETB P0.3CALL PLAY_CB;CLR P0.7MOV A, #1;CALL DELAY;SETB P0.7JB 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.4MOV 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;RETPLAY_DO: ; subroutine to play DO6 (C6)MOV R1, #50 ; ad the no. of time L1 loop is repeatedD1_L1: MOV R0, #21 ; he no. of time L2 loop is repeatedD1_L2: MOV TH0, #HIGH(-426) ; load TH0 register from high byte addressMOV TL0, #LOW(-426) ; load TL0 register from low byte addressSETB TR0 ; start Timer 0JNB TF0, $ ; wait until Timer 0 overflowsCLR TR0 ; stop Timer 0CLR TF0 ; clear Timer 0 overflow flagCPL P2.0 ; complement P2.0 for tone generationDJNZ R0, D1_L2 ; jump to D1_L2 until R1 is decreased to 0DJNZ R1, D1_L1 ; jump to D1_L1 until R2 is decreased to 0CLR P2.0 ; switch off buzzerRET ; exit subroutinePLAY_CO: ; subroutine to play DO6 (C6)MOV R1, #50 ; ad the no. of time L1 loop is repeatedC1_L1: MOV R0, #21 ; he no. of time L2 loop is repeatedC1_L2: MOV TH0, #HIGH(-478) ; load TH0 register from high byte addressMOV TL0, #LOW(-478) ; load TL0 register from low byte addressSETB TR0 ; start Timer 0JNB TF0, $ ; wait until Timer 0 overflowsCLR TR0 ; stop Timer 0CLR TF0 ; clear Timer 0 overflow flagCPL P2.0 ; complement P2.0 for tone generationDJNZ R0, C1_L2 ; jump to D1_L2 until R1 is decreased to 0DJNZ R1, C1_L1 ; jump to D1_L1 until R2 is decreased to 0CLR P2.0 ; switch off buzzerRET ; exit subroutinePLAY_EO: ; subroutine to play DO6 (C6)MOV R1, #50 ; ad the no. of time L1 loop is repeatedE1_L1:MOV R0, #21 ; he no. of time L2 loop is repeatedE1_L2: MOV TH0, #HIGH(-379) ; load TH0 register from high byte addressMOV TL0, #LOW(-379) ; load TL0 register from low byte addressSETB TR0 ; start Timer 0JNB TF0, $ ; wait until Timer 0 overflowsCLR TR0 ; stop Timer 0CLR TF0 ; clear Timer 0 overflow flagCPL P2.0 ; complement P2.0 for tone generationDJNZ R0, E1_L2 ; jump to D1_L2 until R1 is decreased to 0DJNZ R1, E1_L1 ; jump to D1_L1 until R2 is decreased to 0CLR P2.0 ; switch off buzzerRET ; exit subroutinePLAY_FO:MOV R1, #50F1_L1: MOV R0, #21F1_L2: MOV TH0, #HIGH(-358)MOV TL0, #LOW(-358)SETB TR0JNB TF0, $CLR TR0CLR TF0CPL P2.0DJNZ R0, F1_L2DJNZ R1, F1_L1CLR P2.0RETPLAY_GO:MOV R1, #50G1_L1: MOV R0, #21G1_L2: MOV TH0, #HIGH(-319)MOV TL0, #LOW(-319)SETB TR0JNB TF0, $CLR TR0CLR TF0CPL P2.0DJNZ R0, G1_L2DJNZ R1, G1_L1CLR P2.0RETPLAY_AO:MOV R1, #50A1_L1: MOV R0, #21A1_L2: MOV TH0, #HIGH(-284)MOV TL0, #LOW(-284)SETB TR0JNB TF0, $CLR TR0CLR TF0CPL P2.0DJNZ R0, A1_L2DJNZ R1, A1_L1CLR P2.0RETPLAY_BO:MOV R1, #50B1_L1: MOV R0, #21B1_L2: MOV TH0, #HIGH(-253)MOV TL0, #LOW(-253)SETB TR0JNB TF0, $CLR TR0CLR TF0CPL P2.0DJNZ R0, B1_L2DJNZ R1, B1_L1CLR P2.0RETPLAY_CB:MOV R1, #50Z1_L1: MOV R0, #21Z1_L2: MOV TH0, #HIGH(-239)MOV TL0, #LOW(-239)SETB TR0JNB TF0, $CLR TR0CLR TF0CPL P2.0DJNZ R0, Z1_L2DJNZ R1, Z1_L1CLR P2.0RETDELAY:MOV R3, ARPT: MOV R2, #250AGN: MOV R1, #250HERE: NOPNOPDJNZ R1, HEREDJNZ R2, AGNDJNZ R3, RPTRETENDSeptember 19, 2015 at 7:10 pm #13304Ashutosh BhattParticipantthe program can be made from flow chart
reverse process is very funny….
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.