Ubuntu下的AT89S52+SDCC+USBASP的開發環境
開發環境IDE:
mcu8051ide
編譯器:
sdcc
sudo apt-get install sdcc
安裝avrdude
sudo apt-get install avrdude
修改參數:
sudo vim /etc/avrdude.conf
#default_serial = "/dev/ttyS0";
default_serial = "/dev/ttyUSB0";
接線:
MOSI (data input) line, with a clock cycle between each bit and the next (on the SCK (clock input) line). MISO (data output) line is used for reading and for code verification, it is only used to output the code from the FLASH memory of the microcontroller. The RST (used to activate the serial Programming) pin, which is normally used to reset the device, is also used to enable the three pins (MOSI, MISO and SCK) to be used for ISP simply by setting RST to HIGH (5V), otherwise if RST is low (0V), your program start running and those three pins, are used normally as P1.5, P1.6 and P1.7.
for AT89S51
#------------------------------------------------------------
# AT89S51
#------------------------------------------------------------
part
id = "8052";
desc = "AT89S51";
signature = 0x1E 0x51 0x06;
chip_erase_delay = 500000;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", "x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", "x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 0;
memory "flash"
size = 4096;
paged = no;
min_write_delay = 4000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 0 0 1 0 0 0 0 0",
" x x x a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 0 1 0 0 0 0 0 0",
" x x x a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
mode = 0x21;
delay = 12;
;
memory "signature"
size = 3;
read = "0 0 1 0 1 0 0 0 x x x 0 0 0 a1 a0",
"0 0 0 0 0 0 0 0 o o o o o o o o";
;
;
for AT89S52
------------------------------------------------
#------------------------------------------------------------
# AT89S52
#------------------------------------------------------------
part
id = "8052";
desc = "AT89S52";
signature = 0x1E 0x52 0x06;
chip_erase_delay = 500000;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", "x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", "x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 0;
memory "flash"
size = 8192;
paged = no;
min_write_delay = 4000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 0 0 1 0 0 0 0 0", " x x x a12 a11 a10 a9 a8", " a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 0 1 0 0 0 0 0 0", " x x x a12 a11 a10 a9 a8", " a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
mode = 0x21;
delay = 12;
;
memory "signature"
size = 3;
read = "0 0 1 0 1 0 0 0 x x x 0 0 0 a1 a0", "0 0 0 0 0 0 0 0 o o o o o o o o";
;
;
-------------------------------------------------------------------------------------------------------------------------------------
測試檔:
/////////////////////////////////////////////////////////////////////////////////////
#include <8052.h>
typedef unsigned int size_t;
#define LED P0_0
void delay(size_t t){
while(t--);
}
void main(){
while(1){
LED = 0;
delay(20000);
LED = 1;
delay(20000);
}
}
/////////////////////////////////////////////////////////////////////////////////////
編譯:
sdcc -mmcs51 main.c
如果無法編譯的原因是header檔案lost可到
usr/share/sdcc/include/mcs51/
這個目錄查看是否有類似的檔頭可用。
燒錄的來源檔:
main.ihx
測試燒錄:
sudo avrdude -p 8052 -c usbasp -e -U flash:w:'./main.ihx'
留言
張貼留言