Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/13/05 13:40
Read: times


 
#89571 - help: programmer code for AT89S52 in C
hello !!
i made a programmer for AT89S52. code is given below. the programmer is showing the desired pattern on a LED being plugged into the port but its not programming the chip.the hardware is a simple circuit with a 40pin ZIF socket and RST permanently on. other components like crystal, oscillator are proper. in short,the hardware has no problem.
what may be the problem? is it something to do with the port output voltage?


#include<stdio.h>
#include<conio.h>
#include<dos.h>

# define PORT 0x0378
void main()
{
clrscr();
FILE*fp;
int i;
char a,b;
int c[4];
fp=fopen("hex.txt","r"); /* code to be bunred in hex */

while(1)
{
a=fgetc(fp);
if(a==EOF)
break;
else
{
if((a>=48)&&(a<=57)) /* hex to bin*/
a=a-48;
else
{
if((a>=65)&&(a<=70))
a=a-55;
else
{
if((a>=97)&&(a<=102))
a=a-87;
else
{
printf("invalid code");
break;
}
}
}
for(i=0;i<=3;i++)
{
b=a/2;
c[i]=a%2;
a=b;
}
for(i=3;i>=0;i--)
{
if(c[i]==0)
{
outportb(PORT,00000000);
delay(100);
outportb(PORT,10000000);
delay(100);
outportb(PORT,00000000);
delay(100);
}
else
{
outportb(PORT,01000000); /* 1st digit for clock*/
delay(100);
outportb(PORT,11000000); /*2nd digit for data*/
delay(100);
outportb(PORT,01000000);
delay(100);
}
printf("%d",c[i]);
if(a==EOF)
{
fclose(fp);
break;
}
}
}
}
getch();
}

please reply soon.



List of 9 messages in thread
TopicAuthorDate
help: programmer code for AT89S52 in C            01/01/70 00:00      
   Gobbledygook!!            01/01/70 00:00      
      How to post code            01/01/70 00:00      
   i have done a similar code            01/01/70 00:00      
      plz upload the code            01/01/70 00:00      
         take care of timings            01/01/70 00:00      
            NT kernels            01/01/70 00:00      
   DOS Only!            01/01/70 00:00      
      timing issue            01/01/70 00:00      

Back to Subject List