user3594029
user3594029

Reputation: 41

Reading time base registers in PowerPC 440 from c code

I'm currently working with a PowerPC 440 embedded processor. I'm trying to read the upper and lower time base registers (TBU and TBL) using some in-line assembly code but the values I get don't change. According to the documentation, the time base "is a 64-bit register which increments once during each period of the source clock, and provides a time reference". It sounds like I should be able to read the contents of these registers using the mfspr instruction.

I've tried it using the following code:

uint32_t tbuval = 0, tblval = 0;
__asm__ volatile("mfspr %0, %[regnum]" : "=r"(tblval) : [regnum]"r"(0x10C));
__asm__ volatile("mfspr %0, %[regnum]" : "=r"(tbuval) : [regnum]"r"(0x10D));

printf("TBU: %d, TBL: %d\n", tbuval, tblval);

If I put this in a loop, I just keep getting identical values for each one. In the datasheet for the processor, the core clock frequency is listed as 100 MHz. If I read the TBU and TBL registers every 1 second, shouldn't they be increasing by about 100 million each time I read them, or is there some part of this that I'm missing?

thanks, Melissa

In the documentation, the memory mapped register GPT0_TBC is also discussed, and I tried to read that using the "lwz" instruction but could not make that work either.

Upvotes: 3

Views: 202

Answers (0)

Related Questions