EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: TheInfernoMan on January 15, 2017, 02:08:12 pm

Title: Code works on AT89S52 but not on AT89C2051
Post by: TheInfernoMan on January 15, 2017, 02:08:12 pm
Hello,
I have a problem running my code (for a school project) on my little PCB with a AT89C2051.
I tested the code on a AT89S52 and on the AT89S52 it works like a charm (on P3, because of ISP)  ^-^

But when I try the code on my AT89C2051 (yes I changed the target (for the addresses)) it dont work.  |O
It goes to "start" but after that, the code did not run :/  :wtf:

Did someone have an idea why it is so? I think about some incompatibility...
Is there a way to optimize the code (it is attached with german commentary) ?

Thanks in advance  :)
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: jesuscf on January 15, 2017, 05:11:48 pm
I think you'll need to change:

fehlgeschlagen:
   MOV R6, 8d
   MOV P1, 0ffh

to:

fehlgeschlagen:
   MOV R6, #8d ; missing '#'?
   MOV P1, #0ffh ; missing '#'?
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: TheInfernoMan on January 15, 2017, 05:15:03 pm
Oh you are right  :palm: :O I try it
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: TheInfernoMan on January 15, 2017, 05:23:11 pm
No sorry, it is still not working  |O
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: jesuscf on January 15, 2017, 05:49:01 pm
No sorry, it is still not working  |O

Check that you have 'MOV R6, #8d' not 'MOV R6, #8dh' (I incorrectly made the constant hexadecimal 0x8d when it should had been decimal 8 in my original reply, but it is changed now).
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: TheInfernoMan on January 15, 2017, 06:06:40 pm
No in my code, it is correct. But still thanks for this idea  ;)
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: jesuscf on January 15, 2017, 09:08:13 pm
One more thing.  Are there push buttons connected to P1.0 to P1.3?  Do you have pull-ups in P1.0 and P1.1?  From the data sheet: "The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal pull-ups. P1.0 and P1.1 require external pull-ups."
Title: Re: Code works on AT89S52 but not on AT89C2051
Post by: TheInfernoMan on January 15, 2017, 09:18:21 pm
Yes it is so, the push buttons are at P1.0-P1.3 with pullups at P1.0 and P1.1