pic/ mikro c question

Thread Starter

dayv3

Joined May 22, 2014
38
Hi,

Just a quick question, I am writing a program for a 16F636 and I wanted to know how large of a number I can count up to
using an unsigned int in mikro c. I wrote an interrupt routine, timer 0, to over flow at about every 1ms. I then used an
unsigned int to count the number of times the counter over flows to make decisions on. I need to count up to about
3 seconds, 3000ms, of over flows. But I am concerned about how large a variable can be since it is a 8 bit processor.
Does the compiler take care of it or do I need to? Do I need to use timer1?

Dave
 

Picbuster

Joined Dec 2, 2013
1,047
this information is in the C micro compiler manual.
@ microchip xc8 it's 16 bits.

Personal question why prefer micro C above XC8 ?

Picbuster
 

Ian Rogers

Joined Dec 12, 2012
1,136
I have always hated the old "int" variable in C An int is an integer and was 8 bit on the old machines..

byte, word and double word... Or Long and long long are more fitting..

If you use unsigned long then you have a integer value up to 4GIG and yes, you can count that high..

Regarding timers... You can buffer the timer overflow and each spill increment a software timer.. This way you can use timer0 and have any length precision you want..
 

spinnaker

Joined Oct 29, 2009
7,830
Hi,

Just a quick question, I am writing a program for a 16F636 and I wanted to know how large of a number I can count up to
using an unsigned int in mikro c. I wrote an interrupt routine, timer 0, to over flow at about every 1ms. I then used an
unsigned int to count the number of times the counter over flows to make decisions on. I need to count up to about
3 seconds, 3000ms, of over flows. But I am concerned about how large a variable can be since it is a 8 bit processor.
Does the compiler take care of it or do I need to? Do I need to use timer1?

Dave

Took me about 2 minutes to figure it out and I don't even use mikro C.

http://download.mikroe.com/documents/compilers/mikroc/pic/help/arithmetic_types.htm

Actually it took me longer to post this.
 

Thread Starter

dayv3

Joined May 22, 2014
38
Thank you for all that helped.

@Picbuster - I was undecided on which one to buy then one day, when I was deciding, I logged onto
the mikroc web site and because it was the day of their 10th anniversary and they had the compiler on sale for $100.
 
Top