Skip to content

Instantly share code, notes, and snippets.

@andrewsclapp
Created August 7, 2020 00:35
Show Gist options
  • Save andrewsclapp/5e1781215dfb9780628399d1a04ba787 to your computer and use it in GitHub Desktop.
Save andrewsclapp/5e1781215dfb9780628399d1a04ba787 to your computer and use it in GitHub Desktop.
TIM4 INT with pindebug
_TIM4_IRQHandler:
; patch test - turn on 1's digit
BSET PB_ODR,#0
; end patch test
; TIM4 interrupt handler for software Rx/Tx
BRES TIM4_SR,#0 ; clear TIM4 UIF
LD A,TIM4RCNT ; test receive step counter
JREQ TIM4_TESTTRANS ; nothing to do - check for transmit
; Receive a bit
BTJT PSIM+IDR,#PNRX,1$ ; dummy branch, copy GPIO to CF
; old 1 line - patch
; 1$: RRC TIM4RXREG
; new 2 lines - patch
; this PC5 mirror works on both A and V display outputs
1$: bccm PC_ODR,#5 ; pindebug: mirror bit to 1000's digit p1 on LED
RRC TIM4RXREG
DEC TIM4RCNT
JRNE TIM4_TESTTRANS
; Receive sequence complete
MOV TIM4RXBUF,TIM4RXREG ; save result
BSET PSIM+CR2,#PNRX ; enable PNRX external interrupt
; patch
MOV TSTAMP ,TIM2_CNTRH
MOV TSTAMP+1,TIM2_CNTRL
; end patch
; patch test - turn off 1's digit
BRES PB_ODR,#0
; end patch test
; fall through
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment