??? 07/01/05 02:42 Read: times |
#96357 - AT89S52 ISP Commands |
Hello Guys,
just looking for some more in depth information on the ISP commands regarding the AT89S52. I a building an ISP programmer using another AT89S52, and hyperterminal. (serial port) YES, YES, I read the datasheet 100 times, but it is quite vague to say the least. Other Atmel datasheets are more detailed, and much easier to understand. Just wondering if anyone knows where to find some good information or maybe source code on the internet. I looked high and low and did not find much info. I am quite certain my problem lies within the enable programming command string. However I cannot seem to read the lock bits, or even the signature bytes. (It reads all FF's) program starts up with welcome screen in hyperterminal. make the selection, i.e, erase, lock, program, read lock bits, read signature bits. Here is most of the code, hopefully someone can tell me what i am doing wrong here. Forgive me if the code is sloppy, i am just a beginner and only doing this for educational purposes. Any advice would be kindly appreciated. I am not looking for a handout, just some friendly advice. Thank you CT at reset, start up with : setb MOSI ; setb MISO ; clr SCK ; clr RST ; ;************************************************* ; Prepare the target AT89S52 for programming. ;enter here with the rst low, sck low, MOSI & MISO high. En_pg_Mode: setb RST ; force target into reset call delay1ms ; wait 1 ms ; Enable writes to code memory. mov a, #0ACh ; send first byte of enable code call shout ; mov a, #053h ; send second byte call shout ; mov a, #055h ; send dummy byte call shout ; mov a, #069h ; send fourth byte call shout ;according to the datasheet ret ;the last byte = output 69h ;when returning back to main,from each routine, ;RST is taken low again. ;************************************************* Read_Sig: mov dptr,#Sigbits_str ; lcall OutStr ; mov r1,#000h ; mov r7,#003h ; Read_Sig1: mov a,#028h ;command byte lcall shout ; mov a,r1 ;address byte ;???not sure on the next instruction ;the datasheet states that the address of the 3 signature bits ;=(000H,100H, & 200H) ; i do not understand the above values can't be 8 bit? anl a,#01Fh ;isolate 5 bits lcall shout ; mov a,#055h ;dummy byte lcall shout ; lcall shin ;read sig byte into acc lcall PutByte ;print it inc r1 ;next byte djnz r7,Read_Sig1 ; ret ; ******************************************************************* Read_Lock: mov a,#024h ;command byte lcall shout ; mov a,#055h ;dummy byte lcall shout ; mov a,#055h ;dummy byte lcall shout ; lcall shin ;read lock byte into acc lcall putbyte ret ;******************************************************************* ;write all lock bits up to mode 4 Lock: mov r1,#0E0h ; mov r7,#003h ; Lock1: mov a,#0ACh ; lcall shout ; mov a,r1 ;lock bit in R1 lcall shout ; mov a,#055h ;dummy byte lcall shout ; mov a,#055h ;dummy byte lcall shout ; inc r1 djnz r7,Lock1 ret ;*************************************************************** shout: ; Shift out a byte, most significant bit first. ; SCK expected low on entry. Return with SCK low. ; Called with data to send in A. mov r7, #8 ; bit counter shout1: rlc a ; move bit into CY mov MOSI, c ; output bit nop ; enforce data setup nop ; setb SCK ; raise clock nop ; enforce SCK high nop ; nop ; nop ; clr SCK ; drop clock djnz r7, shout1 ; next bit ret ;*************************************************************** ; Shift in a byte, most significant bit first. ; SCK expected low on entry. Return with SCK low. ; Returns received data byte in A. shin: mov r7, #8 ; bit counter shin1: setb SCK ; raise clock mov c, MISO ; input bit rlc a ; move bit into byte nop ; enforce SCK high nop ; clr SCK ; drop clock nop ; enforce SCK low nop ; djnz r7, shin1 ; next bit ret Erase: acall En_Pg_Mode ; mov a, #0ACh ; send first byte of erase call shout ; mov a, #080h ; send second byte call shout ; mov a, #055h ; send third byte (dummy byte) call shout ; call delay10ms ; wait 10 milliseconds ret |
Topic | Author | Date |
AT89S52 ISP Commands | 01/01/70 00:00 | |
some ideas | 01/01/70 00:00 | |
Be warned... | 01/01/70 00:00 | |
ISP commands | 01/01/70 00:00 | |
look here | 01/01/70 00:00 | |
midi | 01/01/70 00:00 | |
Start a new thread... | 01/01/70 00:00 | |
... but first![]() | 01/01/70 00:00 |