...almost winning the lottery.
Ok. So I used the AT89S52 numerous times on my target board as well as in my programmer and things are successful. So now I choose the AT89LP52 because its claimed to be a direct replacement for the AT89S52 and it claims to offer faster speed.
The problem is no matter what I do, the chip wont run the code. I can inject the code into the microcontroller and read it back, but it won't execute.
On my board, I have an AT89C4051 along with HM628128-ALP-7 (128KB ram) that the AT89S52 is able to talk to with 11.0592Mhz attached to it. (was 22.1184Mhz). As soon as I change the micro to AT89LP52, the micro doesn't do anything.
What my code is supposed to do at the beginning is have AT89LP52 talk to AT89C4051 then after that, test ram.
As a sanity test, I inserted the following lines of code at the beginning:
mov P2,#0Fh mov P0,#0F0h
When its time to test memory, I set those two ports back to value 0FFh so memory tests can begin. with the AT89LP52, nothing has happened. I even used the voltmeter to measure voltages on the individual port pins and nothing suggests that those pins were setup correctly even though my code is correct.
The one thing I did not change hardware wise are the capacitors surrounding the crystals. When I use the AT89LP52, I added these three lines before setting the port values just to see if I can get marginally faster performance (but nothing happens):
mov MEMCON,#0h mov AUXR,#0Eh ;slow wait states + use all ext ram mov CLKREG,#052h ;sys div 2, timer div 6
What am I doing wrong? Do i need to do any other special hardware or software setup?
I want to still make the serial port at 56kbps baud but I want the processor to run much faster (at least 3x) than the AT89S52
And the hardware difference is....
on the PDIP package
Pin 31 >> POL: Reset polarity on the AT89LP52
Pin 31 >> |EA/VPP : External Address Enable / 12 volt programming voltage on the AT89S52
Check Pin 31!
Pin 31 through 39 in all my designs are connected to VCC through a 10K resistor bus. The AT89S52, recognizes this pin as logic high and therefore fetches all instructions from internal code memory.
My reset pin setup is 100K resistor from reset pin to ground and 0.047uF capacitor from reset pin to VCC. The AT89S52 recognizes this properly by doing a brief reset upon power on.
Your code, which obviously runs on the AT89S51 part, is obviously not running on the AT89LP51. So I can only assume that it is some difference between the AT89S51 and AT89LP51. Not having your schematic and configuration settings, the only thing I can suggest is that you read section 2.3 Comparison to AT89S51/52 in the AT89LP51 datasheet. (http://ww1.microchip.com/downloads/en/DeviceDoc/do...) I am confident you will find the answer.
I stared at that datasheet for a few hours. Yes it offers "compatibility mode" but I want faster execution. Even trying to execute port manipulating instructions at the beginning of my code is troublesome for the AT89LP series. I never had trouble like this on the AT89S52.
The power to it is 4.8V (USB power filtered through an LM2940 regulator) and crystal is 11.0592Mhz with 33pF capacitors.
And this is where having an oscope would be handy. You could load code that all it does is init an output pin, then loop, just toggling the pin. The oscope would see it wiggling.. You could use an LED, but you would need to build in some sort of delay, like
init pin = out
loop N times pin = 1
loop N times pin = 0
end forever loop
The key here is do something simple. Remember - the keys to debugging anything are think, and simplify, simplify, simplify...
Keep banging the rocks together...
That's why I set port pin values and used a multimeter as a test. I mean the only other thing I could use is an LED.
Sorry if some are confused, but the chips I'm dealing with are the AT89S52 and AT89LP52.
I also just tried reconfiguring port mode for the AT89LP52 so that port 3 is multifunctional and port 1 acts as just ports and that made no difference. I feel like I have to configure more stuff than what Atmel is telling me to configure. So much for compatibility, but nevertheless, I'll read an article someone pointed to me above.
Ahem: "Welcome to the real world, kid." Keep at it. We all have these scars.
Remember - simplify, simplify, simplify.
This is the kind of issue that takes 2..3 hours or 3 days. And the 3 day bugs generally resolve to 1..2 lines of code or a line in a datasheet that flips to reality.
OK, Now this confuses me a bit... I read:
...Note that in some cases, external capacitors C1 and C2 may NOT be required due to the on-chip capacitance of the XTAL1 and XTAL2 inputs (approximately 10 pF each).
Question is, what are these cases? and could I lower them some more so that they are still compatible with AT89S52 in case I need to switch back? Should I replace the 33pF ceramics with 10pF ceramics?
I say this gently: You need to try things like swapping the caps before posting. You need to do your homework first. And this is where an oscope is critical. If you have the oscope, you could check the clock.
You can also call the tech support line at
Atmel Microchip. That is what they do, and they get sad and lonely if nobody calls.
Pro tip: If you have a nerd-level question you just cannot find an answer for (and tech support would not be able to help), you can call the company (like Microchip) and ask for the admin of the Director/VP of Engineering. Be polite - you do not want to ever piss off the admins. Explain you have a nerd-level question you cannot find the answer to. (Don't tell the admin the question - not yet the right person.) That admin will give you to the admin of the next level down. Repeat you have a nerd-level question. In no more than three (max 4) levels, you will get to the nerd who can answer your question.
I used this to get an obscure part number for a connector on a medical device. Within 3 links I got to the guy with the right BOM who gave me the part number. While he was on the line, I used Mr Google to find the part from a sole-source vendor. $30 later, I had the part.
Thats crazy that you had to do all that. I'll still be experimenting with this chip at all levels in hopes I'll get something successful. Worst case, I'll get some AT89S8253's in the mail that can hopefully work. I mean right now, anything with a speed improvement is better than AT89S52.
If you mean following the admin tree, it was quick. I had the part number in less than 10 minutes. I have used the same technique for obscure nerd questions and always found the exact nerd I needed. Only use it for dire things.
Pro tip: if you work in a medium/large company, never piss off the admins or techs. If you do, you will never get things done. If you are in a manufacturing environment, never piss of the mafia - the small group of little old ladies that are at the bottom of the org chart, but have been there since God was in short pants. Just watch the flow of people && you will spot the mafia. If you piss them off, you will never get help on anything - but if time is tight, they can save your ass.
This works for admins and the mafia. Introduce yourself - of course, be polite. Bring them a nice ceramic bowl and a large bag of M&Ms. Explain you are new (they will already know that), and you just want them to remember you if they ever need something and you can help. Techs usually want beer. (Most companies frown/forbid beer on site, so see if you can hang with them at a local brew pub once or twice. Buy the first round.) They can save your ass on critical projects.
"anything with a speed improvement is better than AT89S52" ... and the wind cried "Atmel !!!"
If you have proven sample code from the manufacturer of the chip, give it a try.
You'll benefit from :
- Certify your hardware
- Compare initialization and overall settings of the manufacturer's code with yours.