MC9S12XDT256 write once registers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S12XDT256 write once registers

1,921 Views
dwhite
Contributor I
I was just burned by a "write once" register (FCLKDIV). I remember reading about others here who have been burned by these in the past. I have a few related questions about these.
 
Does anyone have a complete list of these registers for my CPU or family?
 
Here is the list I have come up with:
 

PLLCTL – SCME bit

COPCTL

TSCR1 – PRNT bit

ICSYS

CANxCTL1 – CANE bit

MODE

MMCCTL1

DIRECT

IRQCR

ECLKDIV

FCLKDIV

CLKSEL

 
 
Is a search of the data sheet for "write once" sufficient to find all cases?
 
When a register description says that just one bit is write once and not the whole register, how is that possible? Does this mean that you can use BCLR and BSET on the other bits and it won't count towards the one time write? Or does this mean you can only change it from 0 to 1 once? In the specific case of the PRNT bit in the TSCR1 register, what happens if I write 0x80 to that register? Can I not set the PRNT bit later? Does it depend on the opcode chosen by the compiler?
 
 
Any insights will be greatly appreciated and helpful to everyone here.
Labels (1)
0 Kudos
2 Replies

345 Views
kef
Specialist I
Pdf search for write once should be sufficient.
 
H
 
Write once means first CPU write access to register is granted and all further write accesses are ignored (until next reset). CPU can't write access specific bits, CPU always write accesses whole peripheral register, always all 8 or 16 bits.
Using C bitfields or BSET/BCLR opcodes CPU still accesses whole peripheral register, all 8/16 register bits, not just few of them.
 
TSCR1 register. TSCR1 bit3 (PRNT) is write once bit. Reset default state of TSCR1 is 0 (and PRNT = 0). Some examples
 
TSCR1_PRNT = 0; // read modify write operation. No matter what code compiler will generate, in any case CPU will read TSCR1 register, then CPU will clear somewhere in CPU memory bit3 of value read from TSCR1, and finally CPU will write resulting value (with bit3 cleared) back to TSCR1. It this is first write access, then PRNT will be locked at 0
 
BCLR  TSCR1,#(1<<3)   // this is the same like C line above
 
 
TSCR1_PRNT = 1; // -"- but locked at 1.
 
BSET  TSCR1,#(1<<3)   // this is the same like C line above
 
 
TSCR1_TEN = 1; // also write locks PRNT, but at ... reset default 0,
 
BSET  TSCR1,#(1<<7)   // this is the same like C line above
0 Kudos

345 Views
JimDon
Senior Contributor III
I have found you always need to refer to the spec sheet and read the section carefully when setting up a module. I would say this is true for and mcu I have programmed.

So I would say that the real lesson to take away is RTM, carefully. Typically n times.
However once you get used to a certain mfg's ways, it gets easier.

This is done mainly to prevent bugs from breaking things too badly. If it is effective or not is a matter of opinion I suppose.
0 Kudos