📄 main4.asm
字号:
;-----------------------------------------------------------------------------
; Assembly main line
;-----------------------------------------------------------------------------
include "m8c.inc"
include "pwm16_1.inc"
include "pwm16_2.inc"
include "E2PROM_1.inc"
include "TX8_1.inc"
include "RX8_1.inc"
area bss (RAM)
export month
export day
export hour
export minute
export tel_status
export indexreg
export odd_even
export temp
export te_second
export te_minute
export ram_lsb
export address_lsb
export address_msb
export temp2
export counter1
export counter2
export dateandtime
export msb_dateandtime
export temp3
export delay
buffer: BLK 50h
temp: BLK 1
month: BLK 1
day: BLK 1
hour: BLK 1
minute: BLK 1
tel_status: BLK 1
tel_status2: BLK 1
indexreg: BLK 1
odd_even: BLK 1
te_minute: BLK 1
te_second: BLK 1
ram_lsb: BLK 1
address_lsb: BLK 1
address_msb: BLK 1
temp_msb: BLK 1
temp_lsb: BLK 1
temp2: BLK 1
counter1: BLK 1
counter2: BLK 1
//bRxData: blk 1 ; Rx data storage area
TRUE: equ 1
FALSE: equ 0
temp3: BLK 1
msb_dateandtime: BLK 1
dateandtime: BLK 8
tempbyte: BLK 8
area text (ROM, REL)
export _main
_main:
mov [tel_status],00h //Telephone is not in-use=00,(Telephone in use=FF)
mov [indexreg],00h //This will hold the index register value
mov [odd_even],00h //This is about writing to dialed number in one memory location
mov [ram_lsb],00h //Temporary call details are in range of 00h-64h memory location
mov [address_msb],0Fh //First 64 byte block will be written to 0FC0+40h = 1000h address
mov [address_lsb],C0h
mov reg[PRT2DR],00h //port2_4 will be 0V (Showing that there is enouh space in ROM)
mov [month],1 //Reset DATE
mov [day],1
mov [hour],0
mov [minute],0
startmodules:
//Check if any key on the phone is pressed?
//If a button is pressed , then Port1_0 will detect this thru the DTMF
//receiver chip(from StD Pin of MT8870D)
M8C_EnableGInt
or reg[INT_MSK0], 20h ;This will be enable the GPIO
call PWM8_1_EnableInt
call PWM8_1_Start
call PWM16_1_Start
call PWM16_2_Start
call TX8_1_Start
call RX8_1_Start
call clearRAM
receivedata:
call RX8_1_Start
call delay //Prevents serial communication error.
mov A,<dateandtime
mov X,A
mov [temp3],A
mov [msb_dateandtime],[temp3]
add [msb_dateandtime],9
.WAIT_FOR_RX_ACTIVE:
call bRX8_1_ReadRxStatus
and A, RX8_RX_ACTIVE
jnz .WAIT_FOR_RX_COMPLETE
jz .WAIT_FOR_RX_ACTIVE ; data byte has not been received
; Receiver is actively receiving data, wait for it to complete
.WAIT_FOR_RX_COMPLETE:
call bRX8_1_ReadRxStatus
push A
AND A, RX8_RX_COMPLETE
jnz .CHECK_RX_ERRORS
pop A
jmp .WAIT_FOR_RX_COMPLETE
; Data completely received now check for errors
.CHECK_RX_ERRORS:
pop A
call bRX8_1_ReadRxStatus ; get the Rx status register
and A, RX8_RX_NO_ERROR ; mask off non-status bits
jz .DATA_RX_WITH_NO_ERRORS ; data is valid - no error detected
; Errors detected in received data - return with error condition
; 1) A is set to FALSE indicating error condition
; 2) bRxData contains the RX status flags for further processing
.RX_ERRORS_FOUND:
// mov [bRxData], A ; bRxData contains the status flags
call bRX8_1_ReadRxData ; Read RxData reg to prevent future overrun error
mov A, FALSE ; Set A to FALSE condition
// jmp receivedata
; No error detected in received data - return with data
; 1) A is set to TRUE indicating NO error condition
; 2) bRxData contians the received data byte
.DATA_RX_WITH_NO_ERRORS:
call bRX8_1_ReadRxData ; get the received data in A
mov X,[temp3]
mov [X],A
inc [temp3]
mov A,[temp3]
cmp A,[msb_dateandtime] ;6Ch
jz end
// mov [bRxData], A ; bRxData contains received data byte
mov A, TRUE ; set a to NO error condition
jmp .WAIT_FOR_RX_ACTIVE
end:
call RX8_1_Stop
call delay //Prevents serial communication error.
call delay //Prevents serial communication error.
mov X,[msb_dateandtime]
dec X
mov A,[x]
cmp A,5Ah
jnz receivedata
mov A,<dateandtime
mov X,A
mov A,[x]
sub A,30h
index asciihextable
mov [temp3],A
rlc [temp3]
rlc [temp3]
rlc [temp3]
rlc [temp3]
inc X
mov A,[x]
sub A,30h
index asciihextable
add A,[temp3]
mov [month],A
inc x
mov A,[x]
sub A,30h
index asciihextable
mov [temp3],A
rlc [temp3]
rlc [temp3]
rlc [temp3]
rlc [temp3]
inc X
mov A,[x]
sub A,30h
index asciihextable
add A,[temp3]
mov [day],A
inc x
mov A,[x]
sub A,30h
index asciihextable
mov [temp3],A
rlc [temp3]
rlc [temp3]
rlc [temp3]
rlc [temp3]
inc X
mov A,[x]
sub A,30h
index asciihextable
add A,[temp3]
mov [hour],A
inc x
mov A,[x]
sub A,30h
index asciihextable
mov [temp3],A
rlc [temp3]
rlc [temp3]
rlc [temp3]
rlc [temp3]
inc X
mov A,[x]
sub A,30h
index asciihextable
add A,[temp3]
mov [minute],A
//Send data to PC
senddata:
cmp [address_msb],0fh
jnz skip
checkforRAM:
mov X,0h
cmp [x],EEh
jnz sendRAM
jmp finished
//mov A,10h
//mov X,00h
skip:
mov [temp_msb],10h
mov [temp_lsb],00h
checkforend:
mov A,[temp_msb]
cmp A,[address_msb]
jnz incrementrom
mov A,[temp_lsb]
cmp A,[address_lsb]
jz sendlast40
//else increment rom
incrementrom:
mov A,[temp_msb]
mov X,[temp_lsb]
romx //sending data
mov [tempbyte],A
and F,FBh //Clear Carry
and A,F0h
rrc A
rrc A
rrc A
rrc A
index hextoasciitable
call sendbyte
mov A,[tempbyte]
and A,0Fh
index hextoasciitable
call sendbyte
inc [temp_lsb]
mov A,[temp_lsb]
cmp A,00h
jnz checkforend
inc [temp_msb]
jmp checkforend
sendlast40:
mov [temp3],40h
sendit:
mov A,[temp_msb]
mov X,[temp_lsb]
romx //sending data
mov [tempbyte],A
and F,FBh //clear carry
and A,F0h
rrc A
rrc A
rrc A
rrc A
index hextoasciitable
call sendbyte
mov A,[tempbyte]
and A,0Fh
index hextoasciitable
call sendbyte
inc [temp_lsb]
dec [temp3]
jnz sendit
mov X,0h
mov A,[x]
cmp A,EEh
jz finished
sendRAM:
mov A,[X]
and F,FBh //clear carry
and A,F0h
rrc A
rrc A
rrc A
rrc A
index hextoasciitable
call sendbyte
mov A,[X]
and A,0Fh
index hextoasciitable
call sendbyte
inc X
mov A,[x]
cmp A,EEh
jnz sendRAM
finished:
nop
jmp receivedata
//jmp finished
ret
export writeflash
writeflash:
mov [tel_status],00h //Telephone is closed.
mov [te_second],00h
mov [te_minute],00h
push X
mov X, SP
mov A, 25 ; cTemperature argument
push A
mov A, 00 ; wByteCount
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -