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