Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

XC800 8-Bit Microcontroller Family: SFRs (special function register)

XC800 8-Bit Microcontroller Family: SFRs (special function register)

Infineon_Team
Employee
Employee
50 replies posted 25 likes received 25 replies posted

There are some mapped SFRs (special function register) in the XC800 architecture which need special access handling. Every mapped SFR access can be interrupted by a higher prior interrupt. The mapping-access needs three steps:
1) set RMAP
2) do modifaction on the SFR
3) clear RMAP
There might be a problem if an interrupt comes between steps two and three. The code within the interrupt service routine is usually not mapped. There are two methods to avoid problems here:
A) Block the interrupt globally before accessing the RMAP and enable globally after accessing RMAP or
B) handle the RMAP in every interrupt service routine, i.e. save status of RMAP, ie. push RMAP on stack, modify RMAP accordingly and pop it back from stack.
The smarter solution is B) because disabling the interrupts globally might lose an interrupt event completely.

Examples for mapped peripherals:
WDT, UART1, T21, MDU, CORDIC, OCDS, FlashRoutines (read and write)

Solution A:
refresh_WDT () {
EA=0;
SYSCON0 |= 0x01; // set RMAP to access WDT register // block interrupts globally WDTCON |= 0x02; // refresh SYSCON0 &=~0x01; // clr RMAP EA=1;// disable interrupts globally }

Solution B:
refresh_WDT () {
SYSCON0 |= 0x01; // set RMAP to access WDT register WDTCON |= 0x02; // refresh SYSCON0 &=~0x01; // clr RMAP }

ISR_1 () {
_push_(SYSCON0);// save RMAP status on stack SYSCON0 &=~0x01; // clr RMAP as an example for modification ...// code in interrupt service routine _pop_(SYSCON0);// restore RMAP status from stack }

0 Likes
69 Views