http://www.bgsoflex.com/megasquirt.asm
and here:
http://www.bgsoflex.com/megasquirt.h
No matter how long I stare at (and test in my emulator) the IN_SCI_TX section, it sends one byte too many - there's always a junk byte sent at the end.
For example, the A command sends the real time variables:
Code: Select all
; RAM Variables - Ordered List for RS232 realtime download - delivered in one pack
secl: ds 1 ; low seconds - from 0 to 255, then rollover
squirt: ds 1 ; Event variable bit field for Injector Firing
engine: ds 1 ; Variable bit-field to hold engine current status
baro: ds 1 ; Barometer ADC Raw Reading - KPa (0 - 255)
map: ds 1 ; Manifold Absolute Pressure ADC Raw Reading - KPa (0 - 255)
mat: ds 1 ; Manifold Air Temp ADC Raw Reading - counts (0 - 255)
clt: ds 1 ; Coolant Temperature ADC Raw Reading - counts (0 - 255)
tps: ds 1 ; Throttle Position Sensor ADC Raw Reading - counts, represents 0 - 5 volts
batt: ds 1 ; Battery Voltage ADC Raw Reading - counts
ego: ds 1 ; Exhaust Gas Oxygen ADC Raw Reading - counts
egocorr:ds 1 ; Oxygen Sensor Correction
aircor: ds 1 ; Air Density Correction lookup - percent
warmcor:ds 1 ; Total Warmup Correction - percent
rpm: ds 1 ; Computed engine RPM - rpm/100
pw: ds 1 ; injector squirt time in 1/10 millesec (0 to 25.5 millisec) - applied
tpsaccel:ds 1 ; Acceleration enrichment - percent
barocor:ds 1 ; Barometer Lookup Correction - percent
gammae: ds 1 ; Total Gamma Enrichments - percent
vecurr: ds 1 ; Current VE value from lookup table - percent
bspot1: ds 1 ; Blank Spot 1
bspot2: ds 1 ; Blank Spot 2
bspot3: ds 1 ; Blank Spot 3
But in the transmit code I see:
Code: Select all
MODE_A
clr txcnt ; Send back all real-time variables
lda #$01
sta txmode
lda #$17
sta txgoal
bset TE,SCC2 ; Enable Transmit
bset SCTIE,SCC2 ; Enable transmit interrupt
bra DONE_RCV
Code: Select all
IN_SCI_TX:
pshh
lda SCS1 ; Clear the SCRF bit by reading this register
clrh
lda txcnt
tax
lda txmode
cmp #$05
beq IN_Q_MODE
cmp #$01
bne IN_V_MODE
IN_A_OR_C_MODE:
lda secl,X
bra CONT_TX
IN_V_MODE
lda ve,x
bra CONT_TX
IN_Q_MODE
lda REVNUM,X
CONT_TX:
sta SCDR
lda txcnt
inca
sta txcnt
cmp txgoal
bne DONE_XFER
clr txcnt
clr txgoal
clr txmode
bclr TE,SCC2 ; Disable Transmit
bclr SCTIE,SCC2 ; Disable transmit interrupt
DONE_XFER
pulh
rti
What am I missing?