[SOLVED] Problem with led blinking system using 8051

Status
Not open for further replies.

Cuongysl

Newbie level 3
Joined
Aug 2, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
21
I'm start to learn 8051 by designing a blinking LED circuit. One of my effect seems to have problem, I think it is because of my code because other effects worked. Please help me check if there is something missing
Code:
Effect2:
  	  mov r1,#5			
start2:
	  mov a,#0FFh		
port0:					
	  rlc a				
	  lcall sdelay
	  mov P0,a			
	  cjne a,#00h,port0	
	  
	  mov a,#0FFh
port1:
	  rlc a
	  lcall sdelay
	  mov P1,a
	  cjne a,#00h,port1
	  
	  mov a,#0FFh
port2:
	  rlc a
	  lcall sdelay
	  mov P2,a
	  cjne a,#00h,port2
      	  
	  mov a,#0FFh
port3:
	  rlc a
	  lcall sdelay
	  mov P3,a
	  cjne a,#00h,port3
      lcall sdelay

	  lcall off			;turn off
	  djnz r1,start2
	  ret

off:
	  mov a,#0FFh 		;turn all led off
	  mov P0,a
	  mov P1,a
	  mov P2,a
	  mov P3,a
	  ret


sdelay:	 				;short delay subroutine
      mov r7,#150			
L1:   mov r6,#100
L2:   mov r5,#2
L3:   djnz r5,$
      djnz r6,L2
      djnz r7,L1
      ret
 

You forgot to report an actual problem with your code.

I guess, code execution doesn't proceed beyond the first loop, because rotating 0xFF repeatedly through carry never gives zero.
 

You forgot to report an actual problem with your code.

I guess, code execution doesn't proceed beyond the first loop, because rotating 0xFF repeatedly through carry never gives zero.

I've run the debugger on keil c and it seemed the code proceed just fine. I've even simulated the HEX file on Proteus and it still worked. Yet when I transferred it to the microcontroller, all the LEDs just kept lighting up when it came to this effect.
 

I've found out my problem. It was a stupid mistake. I supposed to connect vcc to EA pin but I connected it to ALE pin instead.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…