Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers > 8051/8951


8051/8951 A specify forum for the Intel 8051/8951 single chip microcontroller.

Reply
 
Tools
Old 1st July 2009, 09:17 AM   #1
Default 8051 & 8052 ??

Hello, i wrote a simple program to to display text on lcd in nibble mode in MikroC. The problem is when i tried this prog on AT89S52 it worked alright, but on AT89S51 it just didnt work (i.e lcd didnt initialize ;just nothing happened) .. i wrote many other simple prog and tested on both ics and all worked but display text in nibble mode isnt working in AT89S51..
__________________
Rεσllγ !!! Mγ Σ×ρer!ence is Directly Propotional τΘ the NΦ of Electronic Items I have Me§§eD µρ ...
tariq7868 is offline  
Old 1st July 2009, 05:43 PM   #2
Default

What is the code.Can you post it?.
__________________
Syed
Wond3rboy is offline  
Old 1st July 2009, 08:26 PM   #3
Default

Quote:
Originally Posted by tariq7868 View Post
Hello, i wrote a simple program to to display text on lcd in nibble mode in MikroC. The problem is when i tried this prog on AT89S52 it worked alright, but on AT89S51 it just didnt work (i.e lcd didnt initialize ;just nothing happened) .. i wrote many other simple prog and tested on both ics and all worked but display text in nibble mode isnt working in AT89S51..
You do realize that they are different parts with subtle differences that are nonetheless spelled out in the datasheets. Right?

When Intel made the originals there was a clear distinction between the two flavors. Atmel did not invent these things, they were always just a second source. One among many.
__________________
We never have time to do it right; but we always have time to do it over.
Papabravo is online now  
Old 1st July 2009, 09:00 PM   #4
Default

Written in 'C ' using MikroC which uses its own libraries ::


sbit LCD_RS at P2.B6;
sbit LCD_EN at P2.B7;
sbit LCD_D7 at P0.B7;
sbit LCD_D6 at P0.B6;
sbit LCD_D5 at P0.B5;
sbit LCD_D4 at P0.B4;



void main() {

lcd_init();
lcd_out(1,5," @$$.Testing 123");
}



Assembly code generated::


_main:
MOV 129, #128
MOV 130, #?ICSlstr1_lcd2+0
MOV 131, hi(#?ICSlstr1_lcd2+0)
MOV R0, #lstr1_lcd2+0
MOV R1, #17
LCALL ___CC2D+0
;lcd2.c,8 :: void main() {
;lcd2.c,9 :: lcd_init();
LCALL _Lcd_Init+0
;lcd2.c,10 :: lcd_out(1,5," @$$.Testing 123");
MOV FARG_LCD_Out+0+0, #1
MOV FARG_LCD_Out+1+0, #5
MOV FARG_LCD_Out+2+0, #lstr1_lcd2+0
LCALL _LCD_Out+0
;lcd2.c,11 :: delay_ms(1000);
MOV R5, 4
MOV R6, 255
MOV R7, 255
NOP
DJNZ R7, -3
DJNZ R6, -7
DJNZ R5, -11
MOV R6, 255
MOV R7, 255
NOP
DJNZ R7, -3
DJNZ R6, -7
MOV R6, 173
MOV R7, 255
NOP
DJNZ R7, -3
DJNZ R6, -7
MOV R7, 143
NOP
DJNZ R7, -3
NOP
;lcd2.c,13 :: }
SJMP #254
; end of _main
__________________
Rεσllγ !!! Mγ Σ×ρer!ence is Directly Propotional τΘ the NΦ of Electronic Items I have Me§§eD µρ ...
tariq7868 is offline  
Old 1st July 2009, 10:37 PM   #5
Default

Quote:
Originally Posted by tariq7868 View Post
Assembly code generated::
_main:
MOV 129, #128
the first line is your problem. The above line is setting up the stack pointer to an address that does not exist in the 89S51. The 89S52 has twice the ram as the 89S51.

If you select the 89S51 in your compiler then the code will work for both the 89S51 and the 89S52.
johnsmith123 is offline  
Old 1st July 2009, 10:58 PM   #6
Default

It would also work if you select the correct processor for each build, or as was suggested make one build that works for both.

Notice from the datasheets that the AT89S52 has peripheral devices and pin functions that are not available on the AT89S51.

Where is the call to delay_ms(1000) that shows up in the assembled output but not in the orginal C-code. Maybe a little fudging going on?
__________________
We never have time to do it right; but we always have time to do it over.

Last edited by Papabravo; 1st July 2009 at 11:00 PM.
Papabravo is online now  
Old 2nd July 2009, 02:53 PM   #7
Default

thnx alot guys ..
__________________
Rεσllγ !!! Mγ Σ×ρer!ence is Directly Propotional τΘ the NΦ of Electronic Items I have Me§§eD µρ ...
tariq7868 is offline  
Old 20th August 2009, 07:36 PM   #8
Default

Quote:
Originally Posted by johnsmith123 View Post
the first line is your problem. The above line is setting up the stack pointer to an address that does not exist in the 89S51. The 89S52 has twice the ram as the 89S51.

If you select the 89S51 in your compiler then the code will work for both the 89S51 and the 89S52.

Good catch...
__________________
Thanks,
Rushikesh
www.projectsof8051.com
rushi53 is offline  
Reply

Tags
8051, 8052

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Multisim 8052 Simulation Question wuchy143 General Electronics Chat 0 4th June 2009 02:09 PM
[Help] Assembly program for 8052 (ADC serial in) xela Micro Controllers 5 26th March 2007 11:43 AM
8051 tearoffear 8051/8951 9 31st August 2006 04:40 PM
PIC vs. 8052... PIC IT IS!!! Steve P Micro Controllers 3 26th August 2005 12:36 PM
Question about 8052.com FAQ Bluesbird Micro Controllers 4 11th April 2005 08:11 PM



All times are GMT. The time now is 05:28 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker