Printf with Long Integers

Questions about the BASICtools and MakeItC
Post Reply
danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Printf with Long Integers

Post by danlee58 »

My 'C' program is reading T1_CR0 from a SuperPro. I want to print the value read to the terminal. The code is:

TIMER_TABLE[k] = T1_CR0; //Read Timer1 Capture Register 0

printf("%ld\n", TIMER_TABLE[k]);

I use %ld to indicate that the value in TIMER_TABLE[k] is a long integer and I want a decimal value.

My terminal prints the character 'd'.



danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Printf with Long Integers

Post by danlee58 »

It does print the long integer when the code is

'printf("%d\n", TIMER_TABLE[k]);'

It doesn't need the Long modifier. MakeitC does give me a warning however.

My real problem is that there are no counts in T1_CR0. I get the Capture Interrupt, but no counts. I have to look at the counter setup again.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: Printf with Long Integers

Post by danlee58 »

My T1 Timer was disabled. I set T1_TCR = 0. It should have been set T1_TCR = 1.

Now my printf statement produces a long decimal number.

Post Reply