/* INT-RC OSC 1.2MHz 2013/11/4 BY M.Kikuchi High Voltage Sirial Programming:Write of Fuse bits 6A-1F Configuration Registers 6A - FF Used Rom 430 bytes ALL Loop = 503.46mS Last Mod 2013/11/7 ATTiny13A - taget IC ATTiny13Aのリセット専用でディバイスチエックはしていない。 0.5秒待ち、0.0035秒で終わる、後はLEDの点滅をする。 */ char LC,R_sdi,R_sii,bit_c; char sdi[] = {0x40,0x6a,0x00,0x00,0x40,0x1f,0x00,0x00}; char sii[] = {0x4c,0x2c,0x64,0x6c,0x4c,0x2c,0x74,0x7c}; sbit SCI at PORTB3_bit; // Clock bit void HV_Clock(){ // SCI clock SCI = 1; SCI = 0; } void bit_set(){ // PORTB = (PORTB & 0xfc); //bit 0 HV_Clock(); bit_c = 0; //loop counter do { if ((R_sdi & 0x80)==0) PORTB0_bit=0; else PORTB0_bit=1; if ((R_sii & 0x80)==0) PORTB1_bit=0; else PORTB1_bit=1; R_sdi <<= 1; R_sii <<= 1; HV_Clock(); bit_c++; } while(bit_c !=8); //bit 1-8 PORTB = (PORTB & 0xfc); //bit 9 HV_Clock(); PORTB = (PORTB & 0xfc); //bit 10 HV_Clock(); } void main() { DDRB=0b00011111; // 1=output PORTB=0; Delay_ms(500); // Wait // Start Pin:SDI,SII,SDO,Reset,Vcc=0 PORTB4_bit = 1; // RESET & Vcc ON DDRB=0b00011011; // SDO=input // for (LC=0;LC<4;LC++){ // Write Fuse Low bits. R_sdi = sdi[LC]; // Instruction 1 to 4. R_sii = sii[LC]; bit_set(); } while(PINB2_bit==0); // busy_check for (LC=4;LC<8;LC++){ // Write Fuse High bits. R_sdi = sdi[LC]; R_sii = sii[LC]; bit_set(); } while(PINB2_bit==0); // busy // end loop DDRB=0b00000100; // 1=output while (1) { Delay_ms(200); // Write over PORTB2_bit=~PORTB2_bit; } }