Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Re: Pic 12f675 c code - ccs compiler

Status
Not open for further replies.

Kandeepan

Junior Member level 1
Joined
Nov 18, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,436
Re: Pic 12f675 c code - ccs compiler

Anybody there to explain me as I'm very new to PIC C programming. What does it mean by " set_timer0(42);"
Looking forward to hear from you soon.

Regards

Kandeepan
 

assasinsareus

Junior Member level 3
Joined
Jul 21, 2010
Messages
25
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,283
Activity points
1,428
Re: Pic 12f675 c code - ccs compiler

Hello,

Im not a common user of the CCS compiler but is it setting the timer count register to 42? Maybe it is also enabling the timer with that value as a fixed rollover value.

eg timers count from 0 to 255 (8-bit) or 0 to 65536 (16-bit). When they rollover from their max count to 0 the timer generates an interrupt. If you preload a value in the count register then the timer will reach it's rollover faster as it has less to count. This timer preloading is useful for accurate timing etc.
 

tahir4awan

Full Member level 4
Joined
Nov 29, 2010
Messages
202
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Location
Germany
Activity points
3,032
Re: Pic 12f675 c code - ccs compiler

yes it is the starting number of timer. Timer0 is an 8bit timer i.e 2^8 = 256 so it counts from 0 to 255.For any reason if you don't want to start timer from 0 you can assign any value (0 - 255). In you example the timer will start from 42 to 255 and set the interrupt flag. The timer will not stop counting after interrupt it will keep on counting from 42 to 255. The timer value is adjusted according to the time requirements.
 

necati

Member level 1
Joined
Mar 27, 2003
Messages
40
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,288
Location
turkey
Activity points
409
Re: Pic 12f675 c code - ccs compiler

///////////////////////////////////////////////
#include <12F675.h>
#use delay(clock=4000000)
#fuses INTRC_IO,NOWDT,NOCPD,NOPROTECT,nomclr
#use rs232(baud=9600,xmit=PIN_A1)
int16 seco=0;

#int_timer0

void ms_100(){

set_timer1(42);

seco++;
}
/////////////////////////////////////////////
void main( void ){
SET_TRIS_A (0b00000101);
setup_adc_ports( NO_ANALOGS );
//SETUP_TIMER_0(t0_internal|T0_DIV_256);//int
SETUP_TIMER_0(T0_EXT_L_TO_H|T0_DIV_1); //ext
enable_interrupts(int_timer0);
enable_interrupts(global);
seco=0;
/////////////////////////////////////////////
while(true){
printf( "\n\r seco:%6ld",seco );
delay_ms(100);
}
}
 

tahir4awan

Full Member level 4
Joined
Nov 29, 2010
Messages
202
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Location
Germany
Activity points
3,032
Re: Pic 12f675 c code - ccs compiler

CCS compiler programing looks similar to BASIC programing.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top