📄 psocgpioint.asm
字号:
;
; PSoCGPIOINT.asm
;
; Data: 29 October, 2001
; Copyright Cypress MicroSystems 2001
;
; This file is generated by the Device Editor on Application Generation.
; It contains the function that services the GPIO interrupt.
;
; Edits to this file will be preserved.
;
include "PSoCGPIOINT.inc"
include "m8c.inc"
include "PWM8_1.inc"
include "E2PROM_1.inc"
export calllogger_GPIO_ISR
calllogger_GPIO_ISR:
//push A
//push X
//and reg[INT_MSK0], DFh ;This will be enable the GPIO
mov X,[indexreg]
mov A,reg[PRT1DR]//Checking Port1_0 if any DTMF is received?
and A,01h
jz no_button_pressed //Probably phone is closed or noise generate an interrupt.
//Button pressed,check if it is the first button.If yes then
//date and time will be recorded for the first button action
cmp [tel_status],FFh //If it is not FF,this means this will be the
//first button , first button will
//make tel_status=FF which means telephone is
//in-use.
jz continuetorecord //Continue to record the other buttons
//First button is now pressed,the date and time will be recorded.
//tel_status will be FFh
firstbutton:
mov X,[indexreg]
mov A,[month]
mov [x],A
inc x
mov A,[day]
mov [x],A
inc x
mov A,[hour]
mov [x],A
inc x
mov A,[minute]
mov [x],A
inc x
mov A,reg[PRT2DR]
and A,0Fh
rlc A
rlc A
rlc A
rlc A
mov [X],A
mov [tel_status],FFh //Telephone is in use.
mov [odd_even],01h //Each byte area in ram will hold two dtmf codes.
call PWM16_2_EnableInt//Time elapsed will be determined in seconds.
//jmp no_button_pressed //Check if a sudden hang up occurs?
jmp end
continuetorecord:
mov A,reg[PRT2DR] //Capture DTMF
mov [temp],A //Save it temporarily
inc[odd_even]
TST [odd_even],01h //Checking if odd_even value is odd or even
jnz nextbyteloc //It is odd.New DTMF code will be written to next byte location
mov A,[temp] //Load captured DTMF to accumalator A
and A,0Fh
add [X],A
jmp end
//jmp no_button_pressed
nextbyteloc:
inc x
mov A,[temp] //Load captured DTMF to accumalator A
and A,0Fh
rlc A
rlc A
rlc A
rlc A
mov [X],A
jmp end
//jmp no_button_pressed
no_button_pressed:
//No dtmf tone is pressed
//check if phone is closed
mov A,reg[PRT0DR] //Checking if phone is closed?
mov reg[ 0xfa], a ;Save data in non-io register
mov a, reg[ 0xfa] ;Synchronized read back into a.This is for preventing the system from
;invalid memory reference errors
and A,01h
jnz end //Phone is still ON
;Resynchronize data in pod and ICE
phoneisclosed:
cmp [tel_status],FFh ;Is the phone was open before?
jnz end //No it was not in use
mov X,[indexreg]
//at least one dtmf is captured
call PWM16_2_DisableInt //Time is calculated.Stop calculating time because phone is closed.
inc x
mov A,[te_minute]
mov [x],A
inc x
mov A,[te_second]
mov [x],A
inc x
mov A,FFh
mov [x],A
inc x
mov [tel_status],00h //Telephone is closed.
mov [te_second],00h
mov [te_minute],00h
//If the 64 byte block is filled then it will be transferred to FLASH
mov A,X
sub A,63
jc end //64 byte block has not filled yet.
initializeflash:
add [address_lsb],40h
cmp [address_lsb],00h
jnz readytowrite
inc [address_msb]
cmp [address_msb],3Fh
jnz readytowrite
//Led will be ON showing that there is only 256 byte remain.
mov reg[PRT2DR],10h //port2_4 will be 5V
readytowrite:
cmp [address_msb],40h
jnz write
cmp [address_lsb],00h
jnz write
jmp writeandresetaddress
write:
call writeflash
jmp transferRAM //Bytes will be transferred to first 64 byte block
writeandresetaddress:
mov [address_msb],3Fh
mov [address_lsb],C0h
call writeflash
mov [address_msb],0Fh
mov [address_lsb],C0h
mov reg[PRT2DR],00h //port2_4 will be 0V
transferRAM:
cmp [63],FFh
jnz transfer
no_transfer:
call clearRAM
mov X,00h
jmp end
transfer:
call clearRAM
mov X,63
mov [temp],FFh
.loop:
inc [temp]
inc x
mov A,[x]
push x
mov [temp2],A //temp2 holds the value of higher 64 byte block
mov X,[temp] //Index register will show the first 64 byte block
mov [x],A //The value in higher64 byte block is transferred to first block
pop x
cmp [X],FFh
jnz .loop
mov X,[temp]
inc X
jmp end
end:
mov [indexreg],X
//or reg[INT_MSK0], 20h ;This will be enable the GPIO
reti
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -