Author Topic: Code works on AT89S52 but not on AT89C2051  (Read 1262 times)

0 Members and 1 Guest are viewing this topic.

Offline TheInfernoMan

  • Contributor
  • Posts: 27
  • Country: de
Code works on AT89S52 but not on AT89C2051
« 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  :)
 

Offline jesuscf

  • Regular Contributor
  • *
  • Posts: 230
  • Country: ca
Re: Code works on AT89S52 but not on AT89C2051
« Reply #1 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 '#'?
« Last Edit: January 15, 2017, 05:40:02 pm by jesuscf »
Homer: Kids, there's three ways to do things; the right way, the wrong way and the Max Power way!
Bart: Isn't that the wrong way?
Homer: Yeah, but faster!
 
The following users thanked this post: TheInfernoMan

Offline TheInfernoMan

  • Contributor
  • Posts: 27
  • Country: de
Re: Code works on AT89S52 but not on AT89C2051
« Reply #2 on: January 15, 2017, 05:15:03 pm »
Oh you are right  :palm: :O I try it
 

Offline TheInfernoMan

  • Contributor
  • Posts: 27
  • Country: de
Re: Code works on AT89S52 but not on AT89C2051
« Reply #3 on: January 15, 2017, 05:23:11 pm »
No sorry, it is still not working  |O
 

Offline jesuscf

  • Regular Contributor
  • *
  • Posts: 230
  • Country: ca
Re: Code works on AT89S52 but not on AT89C2051
« Reply #4 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).
Homer: Kids, there's three ways to do things; the right way, the wrong way and the Max Power way!
Bart: Isn't that the wrong way?
Homer: Yeah, but faster!
 

Offline TheInfernoMan

  • Contributor
  • Posts: 27
  • Country: de
Re: Code works on AT89S52 but not on AT89C2051
« Reply #5 on: January 15, 2017, 06:06:40 pm »
No in my code, it is correct. But still thanks for this idea  ;)
 

Offline jesuscf

  • Regular Contributor
  • *
  • Posts: 230
  • Country: ca
Re: Code works on AT89S52 but not on AT89C2051
« Reply #6 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."
Homer: Kids, there's three ways to do things; the right way, the wrong way and the Max Power way!
Bart: Isn't that the wrong way?
Homer: Yeah, but faster!
 

Offline TheInfernoMan

  • Contributor
  • Posts: 27
  • Country: de
Re: Code works on AT89S52 but not on AT89C2051
« Reply #7 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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf