| ??? 08/06/11 11:58 Read: times |
#183230 - modified code Responding to: ???'s previous message |
Thanks andey for your suggession.
Now I modified the delay routine. Now can any tell me the mistake in this code. The code are as below Thanks
/*
Led display program using 16K33 (20 pin package) with 89s52 controller
*/
#include <c:c51incstdio.h>
#include <c:c51increg52.h>
#include <c:c51incintrins.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long int
#define SDA P25
#define SCL P24
uint ms10;
uchar dly2;
int stop(),
start(),
delay(),
outdata(),
shout(unsigned char serialout),
init_driver();
int init_driver() /*Driver initialisation program start here */
{
start(); //start command to HT16K33
shout(0x00); //display data address pointer
shout(0x21); //Turns on internal oscillator
shout(0x81); //Display on blinking off
shout(0xef); //Dimming set to 16/16
stop();
SDA = 1;
SCL = 1;
}
int outdata() /*Driver initialisation program start here */
{
start(); //start command to HT16K33
shout(0xe0); //slave address
shout(0x01); //command reg address byte display address set to 0x01
shout(0x55); //data byte 4 segnent turns on & 4 turns off
stop(); //stop command
SDA = 1;
SCL = 1;
}
stop() //stop subroutine for HT16K33
{
SDA = 0;
SCL = 1;
_nop_();
SDA = 1;
_nop_();
_nop_();
_nop_();
}
start() //start subroutine for HT16K33
{
SDA = 1;
SCL = 1;
_nop_();
SDA = 0;
_nop_();
_nop_();
SCL = 0;
_nop_();
}
int shout(unsigned char serialout) //Data transfer to HT16K33 subroutine
{
unsigned char eepromcounter;
eepromcounter = 0x08; //8 bit data transmission so counter loaded with 0x08
while(eepromcounter) //while counter does not become 0 out data to 16K33
{
serialout = serialout << 1; //left shift datareg
_nop_();
SDA = CY; //move carry on SDA line
_nop_();
SCL = 1; //give clock pulse
_nop_();
_nop_();
_nop_();
_nop_();
SCL = 0;
--eepromcounter; //decrement the counter by 1
}
SDA = 1; //make SDA high
_nop_();
_nop_();
SCL = 1; //give clock pulse
_nop_();
_nop_();
SCL = 0;
}
delay() //delay routine
{
for(dly2 = 0;dly2 < 12;dly2++);
}
void main(void)
{
SP = 0xa0;
delay(); //give power on delay of greater than 100 ms
TMOD = 0x11; //0001 0001 //both timers are initialised to 16 bit mode
TR0 = 1;
TR1 = 1;
TH0 = 0xfc; //load timer 0 for 1 ms
TL0 = 0x17;
TH1 = 0xec; //load timer 1 for 5 ms
TL1 = 0x78;
P0 = 0xff; //make all port as output port
P1 = 0xff;
P2 = 0xff;
P3 = 0xff;
init_driver(); //call driver initialisation routine
IE = 0x8a;
for(;;);
}
timecalc() interrupt 1 using 1
{
TH0 = 0xfc;
TL0 = 0x17;
++ms10;
if(ms10 > 1000) //1 sec timer
{
ms10 = 0;
outdata(); //every 1 sec give o/p to HT16K33
}
}
time() interrupt 3 using 3
{
TH1 = 0xfc;
TL1 = 0x17;
}
|
| Topic | Author | Date |
| Driving HT16K33 using 89S52 | 01/01/70 00:00 | |
| How to post legible source code | 01/01/70 00:00 | |
| HLL Delay Routines - beware!! | 01/01/70 00:00 | |
| modified code | 01/01/70 00:00 | |
| How do you think that will help?? | 01/01/70 00:00 | |
| some comments on code | 01/01/70 00:00 | |
| testing of new code | 01/01/70 00:00 | |
| HLL Delay Routines | 01/01/70 00:00 | |
| one thing | 01/01/70 00:00 | |
| CY in C ? _NOT_ | 01/01/70 00:00 | |
| I'll use new code. | 01/01/70 00:00 | |
| Getting success | 01/01/70 00:00 | |
| one modification | 01/01/70 00:00 | |
| For How Long? | 01/01/70 00:00 | |
| No need to use that instruction | 01/01/70 00:00 | |
| Start by caring about the C standard | 01/01/70 00:00 | |
Learning the 'C' programming language | 01/01/70 00:00 | |
| C Language Supports No Carry Bits | 01/01/70 00:00 | |
| Talking to HT16K33 | 01/01/70 00:00 |



