Hello,
no, there are no interrupts. i show yo the complete source, but the source do not important things. I want to test some functions of the HC12 only. As Output at may terminal I see the curious phenomenon, that TCNT Register has the following values: a1=38; a2=44; a3=50;....;ax=122; ax+1=128; ax+2=129,ax+3=129;.... until TCNT=128 the variables change with add 6, but then with add1. Why? I find in the Manual the following text by the TCNT-Register discribtion, can this be the reason?
"
The 16-bit main timer is an up counter. A full access for the counter register should take place in one clock cycle. A separate read/write for high byte and low byte will give a different result than accessing them as a word.Read anytime.
Write has no meaning or effect in the normal mode; only writable in special modes (SMODN = 0). The period of the first count after a write to the TCNT registers may be a different size because the write is not synchronized with the prescaler clock."
Code:
#include "stdlib.h"#include "stdio.h"#include "912d128.h"#include "sci.h"volatile int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23;void main(){ // Timer Setup TSCR = 0x80; // Timer enable TMSK2 = 0x03; // Prescaler = 8 (1tick all 1µs) SCI0Init(); while(1) { a1=TCNT; a2=TCNT; a3=TCNT; a4=TCNT; a5=TCNT; a6=TCNT; a7=TCNT; a8=TCNT; a9=TCNT; a10=TCNT; a11=TCNT; a12=TCNT; a13=TCNT; a14=TCNT; a15=TCNT; a16=TCNT; a17=TCNT; a18=TCNT; a19=TCNT; a20=TCNT; a21=TCNT; a22=TCNT; a23=TCNT; SCI_OutString("x"); SCI_OutUDec(a1); SCI_OutString("y"); SCI_OutUDec(a2); SCI_OutString("z"); SCI_OutUDec(a3); SCI_OutString("zz"); SCI_OutUDec(a4); SCI_OutString("y"); SCI_OutUDec(a5); SCI_OutString("z"); SCI_OutUDec(a6); SCI_OutString("zz"); SCI_OutUDec(a7); SCI_OutString("y"); SCI_OutUDec(a8); SCI_OutString("z"); SCI_OutUDec(a9); SCI_OutString("zz"); SCI_OutUDec(a10); SCI_OutString("y"); SCI_OutUDec(a11); SCI_OutString("z"); SCI_OutUDec(a12); SCI_OutString("zz"); SCI_OutUDec(a13); SCI_OutString("y"); SCI_OutUDec(a14); SCI_OutString("z"); SCI_OutUDec(a15); SCI_OutString("zz"); SCI_OutUDec(a16); SCI_OutString("y"); SCI_OutUDec(a17); SCI_OutString("z"); SCI_OutUDec(a18); SCI_OutString("zz"); SCI_OutUDec(a19); SCI_OutString("zz"); SCI_OutUDec(a20); SCI_OutString("y"); SCI_OutUDec(a21); SCI_OutString("z"); SCI_OutUDec(a22); SCI_OutString("zz"); SCI_OutUDec(a23); }}