マイコンSTC12C5204ADの使い方2


使用機材
aitendo_8051コアマイコン [STC12C5204AD]
aitendo_USB-TTL変換モジュール [U2TL2303-10P]
aitendo_抵抗内蔵角形LED [LED234R-WC5V]
ブレッドボード

回路
マイコンPORT/
3/--10K--GND
4/--USB-TTL変換TX
5/--USB-TTL変換RY(RX?)
12(P2.4)/--LED--GND
14/--GND--USB-TTL変換GND
28/--+5V--USB-TTL変換5V

配線をチェックします。
------------------------------------------------------
aaa@aaa:~/Desktop/8051シリアル/prog1/1$ stcgal
Waiting for MCU, please cycle power: done
Protocol detected: stc12b
Target model:
Name: STC12C5204AD
Magic: E164
Code flash: 4.0 KB
EEPROM flash: 2.0 KB
Target frequency: 11.290 MHz
Target BSL version: 6.6H
Target options:
reset_pin_enabled=True
low_voltage_reset=False
oscillator_stable_delay=32768
por_reset_delay=short
clock_gain=high
clock_source=external
watchdog_por_enabled=False
watchdog_stop_idle=True
watchdog_prescale=256
eeprom_erase_enabled=False
bsl_pindetect_enabled=False
Disconnected!
aaa@aaa:~/Desktop/8051シリアル/prog1/1$
------------------------------------------------------

下記プログラムをprog1.cとします。
------------------------------------------------------
#include <8052.h>
void delay(void);
void main(void)
{
while(1)
{
P2_4 = 0xFF;
delay();
P2_4 = 0x00;
delay();
}
}
void delay(void)
{
int i,j;
for(i=0;i<0xff;i++)
for(j=0;j<0xff;j++);
}
------------------------------------------------------

sdccでコンパイルし、stcgalでチップに書き込みます。

------------------------------------------------------
aaa@aaa:~/Desktop/8051シリアル/prog1/1$ ls
prog1.c
aaa@aaa:~/Desktop/8051シリアル/prog1/1$ sdcc prog1.c
aaa@aaa:~/Desktop/8051シリアル/prog1/1$ ls
prog1.asm prog1.ihx prog1.lst prog1.mem prog1.rst
prog1.c prog1.lk prog1.map prog1.rel prog1.sym
aaa@aaa:~/Desktop/8051シリアル/prog1/1$ stcgal prog1.ihx
Waiting for MCU, please cycle power: done
Protocol detected: stc12b
Target model:
Name: STC12C5204AD
Magic: E164
Code flash: 4.0 KB
EEPROM flash: 2.0 KB
Target frequency: 11.347 MHz
Target BSL version: 6.6H
Target options:
reset_pin_enabled=True
low_voltage_reset=False
oscillator_stable_delay=32768
por_reset_delay=short
clock_gain=high
clock_source=external
watchdog_por_enabled=False
watchdog_stop_idle=True
watchdog_prescale=256
eeprom_erase_enabled=False
bsl_pindetect_enabled=False
Loading flash: 155 bytes (Intel HEX)
Switching to 19200 baud: testing setting done
Erasing 2 blocks: done
Writing flash: 640 Bytes [00:00, 2311.09 Bytes/s]
Finishing write: done
Setting options: Protocol error: incorrect magic in option packet
Disconnected!
aaa@aaa:~/Desktop/8051シリアル/prog1/1$
------------------------------------------------------

下記写真に結果を示します。