Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // what is this code supposed to do?:
- // - setup dptr to point to the sample buffer
- // - wait for bit 2 on port B to become 0 (fixed trigger for now)
- // - activate time 1
- // - wait until timer 1 overflow bit is set and store a sample
- // - do this 16*0x100 times
- // - exit
- // TIMER SETUP
- // timer 1 ticks a 1 us ->
- TH1 = 0xff - 2; // set timer 1 reload value
- TL1 = 0xff - 2; // set timer 1 value
- __sbit __at (0xB0+7) TF1;
- // DATA ACQUISITION
- __asm
- // load sample ptr
- mov dpl, #0 //#(samples & 0xff) // is a 256 byte boundary so it is actually 0
- mov dph, #(_samples >> 8)
- mov r0, #0
- mov r1, #0
- // wait for trigger condition
- 00001$:
- mov A, _IOB
- anl A, 0x02
- cjne A, 0, 00001$
- // trigger condition is met, start timer
- orl _TCON, #0x40
- // put sample into buffer
- 00002$:
- mov A, _IOB
- movx @DPTR, A // store samples
- inc DPTR
- // movx @R0, A
- inc R0
- // cjne dpl, #0, 00003$
- cjne R0, #0, 00003$
- inc r1
- // inc dph
- cjne r1, #16, 00003$
- sjmp 00004$
- 00003$:
- // jbc _TCON.7, 0002$
- jbc TF1, 0002$
- sjmp 00003$
- 00004$:
- __endasm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement