Hi, I want to access the ADC0804 which is connected as the memory mapped device at 0x0001. Initially, I want check whether, address and data bus is working fine. For the same, I wrote the code as :::::Program 1::::: #include <p89v51rx2.h>
volatile unsigned char xdata *p = (char xdata *)0x0000; sbit LED = P3^0;
void main() { int j = 0;
while(1) { p[0] = 0x55; for(j=0; j<=2500; j++); LED = 0; p[1] = 0xAA; for(j = 0; j<=2500; j++); LED = 1; } }
:::::: Program 2:::::::::::::::: #include <p89v51rx2.h> #include <absacc.h>
volatile xdata at 0x1000 unsigned char config; volatile xdata at 0x1001 unsigned char config1; sbit LED = P3^0;
void main() { int j = 0; while(1) { config = 0xAA; for(j=0; j<=2500; j++); LED = 0; config1 = 0x55; for(j = 0; j<=2500; j++); LED = 1; } }
Program 1: LED Blinks but, there is no ALE or BUS transisitions. Program 2: Compiler through error that missing ; before 0x1000. This code I have refered from one of 8051 SBC webpage.
Kindly let me know what is the wrong? Is it, I need to set something in compiler? Iam using Keil uV4.
With thanks...
Check the Assembly code being generated. Can you see the MOVX instruction? Possibly simulate it on simulator software (labview or proteus or keil). Check the Vcc and Gnd voltages. Port0 needs pull-up resistors (generally 10K). Also check if the clock pulses are present on Xtal1?
Dhaval Solanki,
Obsolutly there is no problem with hardware, As I could able to toggle the LED. I tried debugged with Keil.. I saw it is executing MOVX command.... In Proteus, this device support is not available.. So, I could not able to simulate....
One more thing... I just tried with AT89C51RD2 in Proteus with out EXTRAM command as not supported by this device. There also, it is not toggling....
Hi, I was using EXTRAM=1; code to enable the xdata <300 address space. Hope, this is not correct eventhough in keil header file it is made as bit addressable. As per datasheet AUXR is not bit addressable. So, I made my program with AUXR = 1; where it sets ALE toggles only when MOVX is executed and address as 0x301. After this change, the bus and ALE pins are toggling.
But, ALE is in reverse order. that is, I am getting signal some thing like logic low. But, as per datasheet or 8051 architecture, it has to be logic high. I don't know why is it soo... In datasheet, I saw that, ALE loading issue: When ALE pin experiences higher loading (>30 pF) during the reset, the microcontroller may accidentally enter into modes other than normal working mode. The solution is to add a pull-up resistor of 3 kW to 50 kW to VDD, e.g., for ALE pin.... So, planning to use 4.7k pull-up and check.... If anybody knows whay is it so, kindly help me...
I am dropping this memory mapped I/O interface and planning to continoue with ports mapped interface as memory mapped interface requires more glu-logic with P89v51rd2 as ALE is not as per specificed in datasheet (might be something I am missing).
My understaning from ALE signal onboard is, ALE is low whenever there is external memory access happens (especially only during MOVX instruction execution) immediate after address latch and ALE is high rest of the time (During controller executes other instructions). If I use glue-logic in hardware I can perform required operation. But, since I am using smaller general purpose PCB, I cannot able to mount n number of device.
Thanks to all for your support...
You need to troubleshoot the hardware. There is definitely some problem with your hardware board. The IC works fine for memory mapped interface(32K RAM + more than 1KB IOs).
Hi Dhaval, The memory whatever you are referring will working with my hardware as well.only problem for me is, the way I want to use requires more glu-logic. I have seen the signal out of ALE pin directly using digital oscilloscope. Based on signal waveform only, I am telling I need more glue logic.
My understanding from the datasheet is different. That is, ALE will be always low and whenever MOVX is executed the ALE toggles. But, the signal out of controller, is different.
As per my understanding, the address should stay on latch 74ls373 until next MOVX is executed. but, it is not. my present hardware is very simple. I connected port0 to D inputs 74ls373, OE of LS373 is permanently connected low and ALE is connected to LE of LS373. So based on datasheet, at every time ALE toggles (getting write signal as well), LSB address should get latched on LS373. It is latching in my hardware as well, but, while executing next instruction, ALE goes high, the address latched disappears. Might be I am missing this controller specific C code to hold ALE low.
The present hardware is made just to see this functionality and interfacing ADC as next step.
However, I am planning to purchase, one more IC to conclude whether the controller, Iam using is defective or what.
I have done port mapped LCD and 4 push button interface design for one of the counting machine using same P89V51RD2 to display event and alarm based on number set in first attempt with out any issue (Software was not mine). Also, I have done other project with Analog device make ADuC841 (8052 core) project for internal ADC based data acqusition with external parallel flash memory interface to store data. So, my hardware never fails as it is not my first hardware project with 8051 and i am in this field for last 11 years with different processor based designs. only problem with me is very less knowledge in software.
There is no doubting on the amount of experience you have.
One more thing... I just tried with AT89C51RD2 in Proteus with out EXTRAM command as not supported by this device. There also, it is not toggling.... The reason for suspecting your hardware.
It cant be and should not be that the even after changing the controller IC, you dont get the ALE toggling correctly.
Try writing an assembly code and then check whether you get the results. And dont use keil for that purpose (that will remove your doubt on software. (use a windows command prompt based x51 tool chain. runs on windows-xp or lower versions only) use both the controllers.
Hi, I will try to check with x51 toolchain. But, I have to learn to do so... If you can refer some weblink will be helpful. However I am going to google for the same... Thanks....