Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

adding all digits in a number, MCU 8051

Status
Not open for further replies.
Ian Rogers said:
You can't just put data on P0 or P1 without controlling the LCD module... The module has its own processor on board (even virtual ones)

That's another problem for persons like me. So, this means that I have to learn to code the LCD module too. Isn't there some kind of ready-made solution so that I don't have to learn the coding of LCD etc.? Please let me know. Thank you very much for being there to help me.

Best regards
PG
 
Last edited:
Hi Rogers

Thank you very much for the help. As a matter of fact, I have never seen any MCU or a LCD in my real life. Anyway, forget about all this idea of LCD interfacing and what we have discussed about this topic previously.

I have successfully tested the code given below in MCU 8051 IDE. And I was able to see characters of the word "AMERICA" sent to port 1 one by one.

Now could you please help me these queries, **broken link removed**, and Q3? Thanks a lot.

Regards
PG


Code:
ORG	0000

        MOV 	DPTR,#MYDATA  	
       	MOV 	R0,#40H     	
       	MOV 	R2,#7     	
  		
	BACK:	CLR 	A        		
        MOVC	A,@A+DPTR   	
     	MOV	@R0,A
	MOV P0, @R0       	
      	INC	DPTR       	
      	INC	R0          	
      	DJNZ 	R2,   BACK  
				
 	HERE: 	SJMP 	HERE
 
      	ORG 	250H
  	MYDATA:	DB	'A','M','E','R','I','C','A'

END
 
Q1..... Look at the data in code.... The first three are 0x90, 0x2 and 0x50.... 0x90 = load DPTR and the 0x2 0x50 is the first position of you message... 'A'
Q2..... LJMP jumps the program anywhere in the code space... LCALL jumps to a routine anywhere in the code space..
Q3..... ASCII is a standard encoding.... each letter, number and punctuation is allocated to a number from 0 to 255... 'A' just happens to be 0x41 or decimal 65...
LCD controller chips know this encoding and can place the correct bitmap accordingly.
 
Last edited:
Thank you.

I understand what LJMP and LCALL generally mean. Actually I wanted to know why the ROM map has 'buttons' for them? What do they have to do there in the ROM map? I hope I'm little clearer this time. Thanks.

Best regards
PG
 
I've had a look... I played with it... I still don't know..... if you load an address and press LJMP it does..... Why!! I'm lost.

Thank you for the reply. Keep playing with it and let me know when you figure out its actual function! :)

As it has been mentioned previously that I have basic knowledge of C++. When writing C++ code I was able to make any section of the code into a comment by simply enclosing it within the two asterisks in the following syntax, /* comment */. I know that in the assembly for 8051 single line comments can be made using a semicolon for each line of the comment. Isn't there a way to make a certain block of a code into a comment without having to use a semicolon for each and every line? Please let me know. Thank you.

Best wishes
PG
 
You do know that arduino IDE / programmer, uses C++ as its primary language.

No, I didn't even know what Arduino was till I visited the Wikipedia after your mentioning of it. Thank you for telling me about it.

I have been struggling to fix the code below for the last two hours without any success. After the addition of the numbers the result is 353D but it should have been 663D. Actually, it's my first attempt to write a little sophisticated code. Could you please tell me where I'm going wrong with it? Thank you.

Code:
;a program to add the following data: 92H, 23H, 66H, 87H, F5H

;we need two registers to accomodate the final addition result, therefore
;R0 and R1 will be used where R1 will contain lower 8 bits of the result

Org 0x0

	Main:
		clr A
		mov R0, #0x0
		mov R1, #0x0
		mov DPTR, #AddData
		mov R2, #5
		
	Repeat:
		clr A
		movc A,@A+DPTR
		add A, R0
		JNC Here
		inc R1
	Here:
		mov R0, A
		inc DPTR
		DJNZ R2, Repeat

	SJMP Main
	

	org 0x40
	AddData: DB 0x92, 0x23, 0x66, 0x87, 0x0F5

end
 
Sorry, I think I was interpreting the end result wrongly. I'm happy that the code was okay.

By the way, I showed MCU 8051 IDE to my instructor today and he really liked it and downloaded it right away and plans to use it in future classes.

The simulator of MCU 8051 IDE has two buttons: step program, step over. To me, they both work the same. Do they really? Please let me know. Thank you.

Best wishes
PG
 
Hi

I'm in big trouble. My MCU 8051 IDE has stopped working. I have reinstalled it more than 10 times, also restarted my computer several times and tried many other ways but it doesn't work. When I try to start it, a window appear. I have attached screenshot of that window. Please help me, please. Thanks

Regards
PG
 
Hi

Yes, I do use AVAST. An application only loads to a sandbox when the antivirus finds something suspicious with it and even then the antivirus gives me an option to run the application normally or in sandbox. In the past AVAST never signaled that there is something wrong with MCU 8051 IDE. I recall a related thing also happened when I was learning C++ that the compiler I was using wasn't running properly, then I was able to solve it by downloading portable version of the compiler. Do you have an application to create portable version? Please help. Thanks.

Regards
PG
 
Last edited:
I just did that. The problem is still there. Yesterday everything was running fine, then I closed MCU 8051 IDE along with many other programs and almost after 15 minutes I tried to run it again and found that error. I even installed it into a different directory. I don't know what else I can do. Perhaps you can tell me.

Regards
PG
 
Other than clearing out the registry entries. I really don't know what you can do to resolve this...... I know what I would do.....ditch millennium... it wasn't compatible with anything...

Xp was, and still is, the most stable windows platform.... Many people refuse to upgrade...

If you open the registry start at the top and select find.... Type in "mcu8051ide" and click find... Every entry of mcu8051ide... just delete the entries..

This is a drastic fix and one only to be undertaken if you feel confident enough.
 
I hope I'm understanding you correctly. I'm not using Windows Millennium. It's Windows XP Professional.

Regards
PG
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top