X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=monolyzer%2Fmain.asm;h=d1cdf77131fab153a7f977d1a708edad24f4f1ce;hb=49b6757e0018cea241ba1cb78d1f48fff991d7fb;hp=bcc6c1c87b1ced5d2b0adff680ac0d58cbe830fe;hpb=1117f788c441bc3d8caf90e5fb883e11696e1757;p=my-code%2Fatmel.git diff --git a/monolyzer/main.asm b/monolyzer/main.asm index bcc6c1c..d1cdf77 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 @@ -130,12 +125,13 @@ MAIN: SAMPLE: - ; sample as long as there is storage capacity - sbrc state,0 - rjmp SAMPLE + ; sample as long as there is storage capacity and signal + cpi state,2 + brne 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 @@ -204,7 +224,7 @@ INT0_IR: brne EXIT_IR ; exit sampling - ldi state,0 + ldi state,2 EXIT_IR: @@ -213,6 +233,13 @@ EXIT_IR: reti +T1_OVF_IR: + + ; exit sampling + ldi state,2 + + reti + ; ; sram