Here is some sample code to access the NVDS on the F1680 in assembly.
This assumes that if it is accessed from a C program that the parameter passing is set to registers.
If accessed from Assembly, then pass the parameters in r8, r9 (from left to right).
I have not included the saving of registers for the calls. Depending on the application you may need to add the push and pops to save the registers.
| Code: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INT16 ReadNVDS(unsigned char addr)
;
; This reads the byte at NVDS location addr.
; The result is returned in a 2 byte value consisting of:
; r0 = Byte, r1 = status
; In C - check status (low byte of return value) and byte is (retval & 0xFF00)
_ReadNVDS:
push r8 ;byte address to access
DI ;disable interrupts
call %4000 ;NVDSRead address (see datasheet)
pop r8
EI ;enable interrupts
ret ;Byte is in R0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BYTE WriteNVDS(BYTE addr, BYTE data)
;
; This writes the byte data at NVDS location addr.
; The result is returned in a 1 byte status
;
_WriteNVDS:
push r8 ;NVDS addr to write
push r9 ;data byte
DI ;disable interrupts
call %43FD ;NVDSWrite routine address (see datasheet)
pop r9 ;clear stack
pop r8
EI ;enable interrupt
ret ;status is in R0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; InitNVDS(INT16 flashval)
;
; This initializes the frequency for the flash controller
; The flashval is system clock Frequency/1000
;
_InitMyNVDS:
ldx FFREQH, r8 ;r8,r9 has clock freq/1000
ldx FFREQL, r9
ret
|