📄 main_hyperterm.lst
字号:
*
541 * PTA[4] = Romeo2 MISO
*
Main_Hyperterm.asm Assembled with CASM08Z 1/28/2003 9:41:14 PM PAGE 14
542 * PTA[3] = Romeo2 SCK
*
543 * PTA[2] = Romeo2 MOSI
*
544 * PTA[1] = Romeo2 /RST
*
545 ****************************************************
******************
E234 [02] 87 546 RomeoConfig: PSHA
E235 [02] A618 547 LDA #!24
;Reset the bit counter.
E237 [04] ADD5 548 BSR MCU_Master
;Set Romeo2 as slave.
549
E239 [05] 4E4043 550 MOV WRITE_SPI,BUFFER
;Buffer the config data.
E23C [05] 4E4144 551 MOV WRITE_SPI+1,BUFFER+1
E23F [05] 4E4245 552 MOV WRITE_SPI+2,BUFFER+2
553
E242 [04] 3845 554 Next_Bit: LSL BUFFER+2
;Shift a data bit into the carry bit.
E244 [04] 3944 555 ROL BUFFER+1
E246 [04] 3943 556 ROL BUFFER
E248 [03] 2516 557 BCS Set
;Check if data = 1 or 0.
558
E24A [04] 1500 559 Clear: BCLR 2,PTA
;Clear the data output pin.
560
E24C [04] 1600 561 Toggle_Clk: BSET 3,PTA
;Set the clock.
E24E [01] 9D 562 NOP
;Wait a little.
E24F [01] 9D 563 NOP
E250 [01] 9D 564 NOP
E251 [04] 1700 565 BCLR 3,PTA
;Clear the clock.
E253 [05] 090000 566 BRCLR 4,PTA,Data_In
;Check state of the data pin (note carry bit).
E256 [04] 3948 567 Data_In: ROL READ_SPI+2
;Shift data bit from carry into register.
E258 [04] 3947 568 ROL READ_SPI+1
E25A [04] 3946 569 ROL READ_SPI
E25C [03] 4BE4 570 DBNZA Next_Bit
;Decrement the bit counter.
E25E [03] 2004 571 BRA Done
572
E260 [04] 1400 573 Set: BSET 2,PTA
;Set data out line to 1.
E262 [03] 20E8 574 BRA Toggle_Clk
;Go toggle the clock.
575
E264 [05] 0E4002 576 Done: BRSET 7,WRITE_SPI,Really_Done
;If MSB is set, we're reading, not writing.
E267 [04] AD02 577 BSR CheckConfig
;Verify the configuration went okay.
E269 [02] 86 578 Really_Done: PULA
E26A [04] 81 579 RTS
Main_Hyperterm.asm Assembled with CASM08Z 1/28/2003 9:41:14 PM PAGE 15
580
581 ****************************************************
******************
582 * CheckConfig
*
583 * Confirms the Romeo2 configuration registers. If
an error (caused *
584 * by data corruption on the wire, or a bad connectio
n to Romeo2), *
585 * all LEDs are turned on until the error is
corrected. *
586 * PTA[4] = Romeo2 MISO
*
587 * PTA[3] = Romeo2 SCK
*
588 * PTA[2] = Romeo2 MOSI
*
589 * PTA[1] = Romeo2 /RST
*
590 ****************************************************
******************
E26B [04] 1E40 591 CheckConfig: BSET 7,WRITE_SPI
;MSB = 1 to read Romeo2 configuration.
E26D [05] CDE234 592 JSR RomeoConfig
593
E270 [03] B646 594 LDA READ_SPI
E272 [03] B140 595 CMP WRITE_SPI
E274 [03] 260E 596 BNE Romeo_Error
E276 [03] B647 597 LDA READ_SPI+1
;Get the configuration data.
E278 [03] B141 598 CMP WRITE_SPI+1
;Check if Romeo2 configured properly.
E27A [03] 2608 599 BNE Romeo_Error
;If a problem, turn on all LEDs.
E27C [03] B648 600 LDA READ_SPI+2
E27E [03] B142 601 CMP WRITE_SPI+2
E280 [03] 2602 602 BNE Romeo_Error
E282 [03] 2007 603 BRA Romeo_OK
;Romeo is configured properly.
604
E284 [05] CDE0F0 605 Romeo_Error: JSR TurnOnLEDs
E287 [01] 9C 606 RSP
;Reset the stack pointer.
E288 [03] CCE3BE 607 JMP Main
;Try again.
608
E28B [04] 81 609 Romeo_OK: RTS
610
611 ****************************************************
******************
612 * GetSPIData
*
613 * SPI slave mode receive routine. Note that the
data are reversed *
614 * in memory: i.e. DATA+7 is the first ID byte,
DATA+6 is the second *
615 * ID byte, and DATA+1 is the status byte. This
makes the code *
Main_Hyperterm.asm Assembled with CASM08Z 1/28/2003 9:41:14 PM PAGE 16
616 * much more efficient.
*
617 * Normally, the time base module is running
generating periodic int- *
618 * errupts. Once the first clock is detected here,
TBM interrupts *
619 * are disabled and the timer starts running. The
timer is used so *
620 * that if a partial frame is sent by the Romeo2
SPI, it will not *
621 * affect the next data frame.
*
622 *
*
623 * Data frame:
*
624 * 4 bytes of ID
*
625 * 1 byte of Pressure data
*
626 * 1 byte of Temperature data
*
627 * 1 byte of Status data
*
628 * 1 byte of Checksum data
*
629 * 1 byte of irrelevant data
*
630 * Perhaps 1 more byte of irrelevant data (see
Romeo2 spec). *
631 * The data are then stored in the 8 bytes labeled
"DATA." *
632 *
*
633 * PTA[4] = Romeo2 MISO
*
634 * PTA[3] = Romeo2 SCK
*
635 * PTA[2] = Romeo2 MOSI
*
636 * PTA[1] = Romeo2 /RST
*
637 ****************************************************
******************
E28C [04] AD95 638 GetSPIData: BSR MCU_Slave
E28E [01] 8C 639 CLRH
640
E28F [02] AE08 641 LDX #NB_DATA
;Byte counter
E291 [04] 1820 642 BSET 4,TSC
;Reset the timer counter registers.
E293 [02] A608 643 Rst_Bit_Cnt: LDA #!8
;Bit counter
644
E295 [05] 0700FD 645 Hold_Low: BRCLR 3,PTA,*
;Clock is initially low: wait here.
E298 [05] 0700FD 646 BRCLR 3,PTA,*
;Debounce
Main_Hyperterm.asm Assembled with CASM08Z 1/28/2003 9:41:14 PM PAGE 17
E29B [04] 151C 647 BCLR 2,TBCR
;Mask TBM interrupts.
E29D [04] 1B20 648 BCLR 5,TSC
;The timer starts counting here.
E29F [05] 0600FD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -