From: hackbard Date: Wed, 16 Feb 2011 15:24:54 +0000 (+0100) Subject: more control X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9e711fa8f239e1ce03993cc2502a2d8df48cd9d;p=my-code%2Fatmel.git more control --- diff --git a/monolyzer/main.asm b/monolyzer/main.asm index bcc6c1c..e17e9a7 100644 --- a/monolyzer/main.asm +++ b/monolyzer/main.asm @@ -35,7 +35,7 @@ reti reti ; T1 OVF1 -reti +rjmp T1_OVF_IR ; T0 OVF0 reti @@ -104,23 +104,18 @@ INIT: ; more init ldi count,0 - ldi state,1 + ldi state,0 ; storage pointer ldi ZL,low(STORAGE) ldi ZH,high(STORAGE) - ; counter - ldi tmp1,0 - out TCNT1H,tmp1 - out TCNT1L,tmp1 - ; signal ready output ldi uart_rxtx,0x72 rcall UART_TX ; external interrupt enable - rcall INT0_IR_CONF + rcall INT0_IR_CONF_INIT rcall INT0_IR_ENABLE ; global interrupt enable @@ -131,11 +126,12 @@ MAIN: SAMPLE: ; sample as long as there is storage capacity - sbrc state,0 + sbrs state,0 rjmp SAMPLE - ; external interrupt enable + ; disable interrupts rcall INT0_IR_DISABLE + rcall TIMER1_INT_DISABLE ; signal finish ldi uart_rxtx,0x66 @@ -159,7 +155,11 @@ TRANSFER: ; reset storage pointer ldi ZL,low(STORAGE) ldi ZH,high(STORAGE) - ldi count,0 + ldi tmp1,0 + + ; transmit number of sampled words + mov uart_rxtx,count + rcall UART_TX TRANSFER_LOOP: @@ -168,10 +168,10 @@ TRANSFER_LOOP: rcall UART_TX ; count sent data - add count,one + add tmp1,one ; check amount of sent data - cpi count,110 + cp tmp1,count breq IDLE rjmp TRANSFER_LOOP @@ -190,9 +190,29 @@ INT0_IR: ; debug output ; cbi PORTD,3 - ; write timer value into sram + ; get timer value in tmp1,TCNT1L in tmp2,TCNT1H + + ; check for initial or running state + cpi state,0 + brne INT0_RUN + + ; configure interrupt for running state + rcall INT0_IR_CONF_RUN + ldi state,1 + + ; reset timer and start ovf interrupt + ldi tmp1,0 + out TCNT1H,tmp1 + out TCNT1L,tmp1 + rcall TIMER1_INT_ENABLE + + rjmp EXIT_IR + +INT0_RUN: + + ; write timer value into sram st Z+,tmp2 st Z+,tmp1 @@ -213,6 +233,13 @@ EXIT_IR: reti +T1_OVF_IR: + + ; exit sampling + ldi state,0 + + reti + ; ; sram diff --git a/monolyzer/port.asm b/monolyzer/port.asm index d3ea524..42c08fa 100644 --- a/monolyzer/port.asm +++ b/monolyzer/port.asm @@ -20,7 +20,17 @@ PORT_INIT: ret -INT0_IR_CONF: +INT0_IR_CONF_INIT: + + ; trigger interrupt on rising edge + in tmp1,MCUCR + sbr tmp1,(1<