I am writing a code to interface 4 SSD with AT89C51 at Port 2 and Port 0. Port 2 is used to select the SSD and the Port 0 lines act as data lines to SSD (through ULN2004). I have written code for the same. And works as expected in keil4 simulator. But the real problem is that the code does not work on AT89C51 IC. So i modified the code to Turn-On and Turn-Off the port pins of all ports. But nothing happens.
Instead square wave is generated on Port 2 pins, such that square wave frequency at P2.0=x, P2.1=2x, P2.2=4x, and so on...(Very typical behaviour). Other port pins remain high.
so i checked the ALE signal, which goes high once every 25mSec. The crystal osc frequency = 12MHz. (i am worried about ALE signal)
The following is the simple code that i programmed just to turn-on & turn-off port pins. Port0 has pull-up resistors.
#include<intrins.h> #include <REGX51.H> bit flg=0; void main() { SP = 0x50; P0 = 0; TMOD = 0x01; //Timer1 - Counter Mode, 16Bit Counter. Timer0 - 16Bit Timer TCON = 0; TH1 = 0; TL1 = 0; TH0 = 0xF6; //F63C To generate delay of 2.5mSec TL0 = 0x3C; //D8F0 to generate delay of 10mSec //FC18 to generate delay of 1msec IT0 = 1; //Interrupt0 -> Negative Edge Triggerred IE = 0; //Disable all interrupts IP = 0; IE = 0x82; TR0 = 1; while(1) ; } void TIMER0_ISR(void) interrupt 1 //5msec interrupt for 7-segment display. { TR0 = 0; TH0 = 0xF6; //F63C To generate delay of 2.5mSec TL0 = 0x3C; //D8F0 to generate delay of 10mSec //FC18 to generate delay of 1msec TR0 = 1; flg = ~flg; if(flg) { P0 = 0xFF; P1 = 0xFF; P2 = 0x00; P3 = 0x00; } else { P0 = 0x00; P1 = 0x00; P2 = 0xFF; P3 = 0xFF; } }
I program the IC using ALL-11 programmer. The hardware is ok.
PS: Have worked on P98V51RD2FN and ARM, Cortex controllers also. But have never faced such a problem.