tiny10À¸·Î pwm2ppm ÄÁ¹öÅ͸¦ ¸¸µé¾ú½À´Ï´Ù. 2chµµ ÃæºÐÈ÷ ÇÒ ¼ö ÀÖ°í Äڵ嵵 ÀÖÁö¸¸ Å×½ºÆ®¸¦ ¾ÈÇغÁ¼ 1chÂ¥¸®¸¦ ¿Ã¸³´Ï´Ù. À̰͵µ »ó´çÈ÷ ´õ Æí¸®ÇÏ°í ÁÁ°Ô ´ÙµëÀ» ¼ö Àִµ¥ ±¸ÂùÀ¸´Ï±î ±¸³É ¾µ¶ø´Ï´Ù. tiny13À» ¾´°Ô °ø°³µÇ¾î ÀÖÁö¸¸ º¯¼Ó±â¿¡ ±â»ýÇϱ⿡´Â Å©±â°¡ Á» Å®´Ï´Ù. ÀÌ°Å´Â º¯¼Ó±â¿¡ ÀÛÀº °ø°£ÀÌ¶óµµ ºñÁý°í µé¾î°¡¼ ±â¼ººÎǰó·³ ÀÚ¸®ÀâÀ» ¼ö ÀÖ½À´Ï´Ù. »ç¿ëÇÏÁö ¾Ê´Â 2ÇÉÀº hi ÀÓÇÇ´ø½º·Î ó¸®Çؼ Àü¿ø´ÜÀÚ¿Í ¼îÆ®½ÃÄѵµ ¹«¹æÇÏ°ÔÇؼ ºÎÂøÀ» ½±°Ô Çß½À´Ï´Ù. /***************************************************** ********** attiny10 pwm2ppm ÄÁ¹öÅÍ 1CH *********** ****************************************************** tiny10 (data) (rst) PB0-[..]-PB3 (-)-- GND-[..]-VCC --(+) out<- PB1-[..]-PB2 <-in (clk)
¼º¸½ÅÈ£ ___-_______--___ ÁÖ±â:16ms ÆÞ½ºÆø:1~2ms PB0,3 : high ÀÓÇÇ´ø½º(ÀÔ·Â) PB1 : ppm½ÅÈ£ out PB2 : pwm½ÅÈ£ in 2012³â 4¿ù 29ÀÏ ÀÌÇÐÁ¾ ¸¸µê ******************************************************/ ; 8Mhz ½Ã½ºÅÛ¿¡¼ 1msec¿¡ »ó´çÇϴ Ŭ·°¼ö ; 8000ȸ / 10Ŭ·°(·çÇÁ´ç) = 800 .equ CNT_1MS = (8000 / 10) .equ PWM_IN = PB2 ; PB2 .equ PPM_OUT = PB1 ; PB1 .equ PERIOD_MS = 22 ; 19 ÀÌ»ó ±ÇÀå .def cnt_h = r16 .def cnt_l = r17 .def loop_h = r18 .def loop_l = r19 .def set_timer = r20 .def temp1 = r21 .def temp2 = r22 .def i_temp1 = r23 ; interrupt temporary .def i_temp2 = r24 ; interrupt temporary .def i_sreg = r25 ; interrupt temporary ;##################################################### .cseg .org 0 rjmp reset nop ; ext0_int nop ; pci0_int nop ; capt0_int rjmp ovf0_int nop ; ccma_int nop ; ccmb_int nop ; comp_int nop ; wdc nop ; vlm nop ; adc version:.db "pwm2ppm_1 v1.0" ;##################################################### reset: ;##### 8Mhz ÁöÁ¤ ldi temp1, 0xd8 ldi temp2, 0 out CCP, temp1 out CLKMSR, temp2 out CCP, temp1 out CLKPSR, temp2 ;##### ÃʱâÈ ldi temp1, (1<<PWM_IN) ; PPM_IN pull-up out PORTB, temp1 ldi temp1, (1<<PPM_OUT) ; PPM_OUT¸¸ Ãâ·ÂÀ¸·Î ¼³Á¤ out DDRB, temp1 ldi temp1, 2 ; (1,2,3,4,5) => clk / (1,8,64,256,1024) out TCCR0B, temp1 ldi temp1, (1 << TOIE0) out TIMSK0, temp1 ser set_timer ldi temp1, high(65536 - (1000*PERIOD_MS)) ldi temp2, low (65536 - (1000*PERIOD_MS)) out TCNT0H, temp1 out TCNT0L, temp2 cbi PORTB, PPM_OUT ; ppm ½ÅÈ£¸¦ '0'À¸·Î sei ;##################################################### ;##### ¸ÞÀηçÇÁ loop: ldi loop_h, high (CNT_1MS * 16) // PERIOD 16msÃÊ ldi loop_l, low (CNT_1MS * 16) clr cnt_h clr cnt_l ;##### 16msµ¿¾È PB1ÀÇ ½ÅÈ£°¡ '1'ÀΠȽ¼ö¸¦ Ä«¿îÆ®ÇÏ¿© cnt_h,l¿¡ ÀúÀå clr temp1 clr temp2 count_on: // 11*(loop_l+1) + (14 + 11*255)*loop_h sbis PINB, PWM_IN ; pwm½ÅÈ£°¡ '1'À̸é Á¡ÇÁ ldi temp1, 0 sbic PINB, PWM_IN ; pwm½ÅÈ£°¡ '0'À̸é Á¡ÇÁ ldi temp1, 1 add cnt_l, temp1 adc cnt_h, temp2 dec loop_l cpi loop_l, 0xff brne count_on dec loop_h cpi loop_h, 0xff brne count_on ;##### º¯¼ö°ª ÀúÀå ; loop_l,h <- CNT_1MS + Ãß°¡ÇÒ ÆÞ½ºÆø ldi loop_l, low (CNT_1MS) ldi loop_h, high(CNT_1MS) lsr cnt_h ror cnt_l lsr cnt_h ror cnt_l lsr cnt_h ror cnt_l lsr cnt_h ror cnt_l ; cnt / 16 ... 1msµ¿¾È Ä«¿îÆ®µÈ '1'ÀÇ ¼ö add loop_l, cnt_l adc loop_h, cnt_h ;##### ppm ÆÞ½º Ãâ·Â clr temp1 clr temp2 sbi PORTB, PPM_OUT ; ppm½ÅÈ£¸¦ '1'·Î delay_plus: sbis PINB, PWM_IN ldi temp1, 0 sbic PINB, PWM_IN ldi temp1, 0 add cnt_l, temp1 add cnt_h, temp2 dec loop_l cpi loop_l, 0xff brne delay_plus dec loop_h cpi loop_h, 0xff brne delay_plus cbi PORTB, PPM_OUT ; ppm ½ÅÈ£¸¦ '0'À¸·Î ser set_timer wait_tmr: tst set_timer brne wait_tmr rjmp loop ;##################################################### ;##### timer interrupt ovf0_int: in i_sreg, SREG clr set_timer ldi i_temp1, high(65536 - (1000*PERIOD_MS)) ldi i_temp2, low (65536 - (1000*PERIOD_MS)) out TCNT0H, i_temp1 out TCNT0L, i_temp2 out SREG, i_sreg reti .exit ;##################################################### /* AVR Studio 5.0¿¡¼ ÄÄÆÄÀÏ pwm2ppm_xy.hex : PBx(in)--->PBy(out) ex)pwm2pp_01.hex : PB0(pwm input)--->PB1(ppm out) ### pwm2ppm_01.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300051E052B952E051B952E05DBD51E05BBDB3 :100040004FEF5AEA60E159BD68BD1198789422E3F8 :1000500030E00027112755276627009B50E00099C4 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627119A4A :10009000009B50E0009950E0150F060F3A953F3F46 :1000A000B9F72A952F3FA1F711984FEF4423F1F7A5 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_02.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300051E052B954E051B952E05DBD51E05BBDB1 :100040004FEF5AEA60E159BD68BD1298789422E3F7 :1000500030E00027112755276627009B50E00099C4 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627129A49 :10009000009B50E0009950E0150F060F3A953F3F46 :1000A000B9F72A952F3FA1F712984FEF4423F1F7A4 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_03.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300051E052B958E051B952E05DBD51E05BBDAD :100040004FEF5AEA60E159BD68BD1398789422E3F6 :1000500030E00027112755276627009B50E00099C4 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627139A48 :10009000009B50E0009950E0150F060F3A953F3F46 :1000A000B9F72A952F3FA1F713984FEF4423F1F7A3 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_10.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300052E052B951E051B952E05DBD51E05BBDB3 :100040004FEF5AEA60E159BD68BD1098789422E3F9 :1000500030E00027112755276627019B50E00199C2 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627109A4B :10009000019B50E0019950E0150F060F3A953F3F44 :1000A000B9F72A952F3FA1F710984FEF4423F1F7A6 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_12.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300052E052B954E051B952E05DBD51E05BBDB0 :100040004FEF5AEA60E159BD68BD1298789422E3F7 :1000500030E00027112755276627019B50E00199C2 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627129A49 :10009000019B50E0019950E0150F060F3A953F3F44 :1000A000B9F72A952F3FA1F712984FEF4423F1F7A4 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_13.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300052E052B958E051B952E05DBD51E05BBDAC :100040004FEF5AEA60E159BD68BD1398789422E3F6 :1000500030E00027112755276627019B50E00199C2 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627139A48 :10009000019B50E0019950E0150F060F3A953F3F44 :1000A000B9F72A952F3FA1F713984FEF4423F1F7A3 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_20.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300054E052B951E051B952E05DBD51E05BBDB1 :100040004FEF5AEA60E159BD68BD1098789422E3F9 :1000500030E00027112755276627029B50E00299C0 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627109A4B :10009000029B50E0029950E0150F060F3A953F3F42 :1000A000B9F72A952F3FA1F710984FEF4423F1F7A6 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_21.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300054E052B952E051B952E05DBD51E05BBDB0 :100040004FEF5AEA60E159BD68BD1198789422E3F8 :1000500030E00027112755276627029B50E00299C0 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627119A4A :10009000029B50E0029950E0150F060F3A953F3F42 :1000A000B9F72A952F3FA1F711984FEF4423F1F7A5 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_23.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300054E052B958E051B952E05DBD51E05BBDAA :100040004FEF5AEA60E159BD68BD1398789422E3F6 :1000500030E00027112755276627029B50E00299C0 :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627139A48 :10009000029B50E0029950E0150F060F3A953F3F42 :1000A000B9F72A952F3FA1F713984FEF4423F1F7A3 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_30.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300058E052B951E051B952E05DBD51E05BBDAD :100040004FEF5AEA60E159BD68BD1098789422E3F9 :1000500030E00027112755276627039B50E00399BE :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627109A4B :10009000039B50E0039950E0150F060F3A953F3F40 :1000A000B9F72A952F3FA1F710984FEF4423F1F7A6 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_31.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300058E052B952E051B952E05DBD51E05BBDAC :100040004FEF5AEA60E159BD68BD1198789422E3F8 :1000500030E00027112755276627039B50E00399BE :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627119A4A :10009000039B50E0039950E0150F060F3A953F3F40 :1000A000B9F72A952F3FA1F711984FEF4423F1F7A5 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF ### pwm2ppm_32.hex ### :020000020000FC :1000000011C000000000000054C00000000000000B :1000100000000000000070776D3270706D5F31205D :1000200076312E3058ED60E05CBF67BF5CBF66BFC5 :1000300058E052B954E051B952E05DBD51E05BBDAA :100040004FEF5AEA60E159BD68BD1298789422E3F7 :1000500030E00027112755276627039B50E00399BE :1000600051E0150F061F3A953F3FB9F72A952F3FEC :10007000A1F730E223E006951795069517950695AA :10008000179506951795310F201F55276627129A49 :10009000039B50E0039950E0150F060F3A953F3F40 :1000A000B9F72A952F3FA1F712984FEF4423F1F7A4 :1000B000CECF9FB744277AEA80E179BD88BD9FBF44 :0200C000189591 :00000001FF */ |