Continue to Site

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.

Need help mikroc timer2 pic16f877a

Status
Not open for further replies.

armghan11

Member level 1
Member level 1
Joined
Oct 9, 2012
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,557
I am a ccs c compiler user but unfortunately have some problems with burning ccs c code with genius programmer.. so i am trying to convert my ccs c code to mikroc as mikroc works perfect with g540. i need little help with timers. here is


my ccs timer2 function:

Code:
#int_TIMER2
void  TIMER2_isr(void)                                           //interrupt handler for timer
{
char i;
count++;
if(count==250) //i.e 1 sec = 245 count at 4Mhz
{
sec++;
count=0;
}
if(sec==60)
   {min[0]++;
      sec=0;
   }
if(min[0]==1)
{
   
   disable_interrupts(INT_TIMER2);
for(i=1;i<5;i++)
{
   if(load[i]) //time update here
   {
    //TimeUpdate(i);
      min[i]++;
   
   if(min[i]==60)
      hour[i]++;
   }  
}
                                                   //saves time value in eeprom 
   write_eeprom(50,hour[1]);
   write_eeprom(51,min[1]);
      write_eeprom(52,hour[2]);
   write_eeprom(53,min[2]);
   write_eeprom(54,hour[3]);
   write_eeprom(55,min[3]);
   write_eeprom(56,hour[4]);
   write_eeprom(57,min[4]);
min[0]=0;
   enable_interrupts(INT_TIMER2);
}
return;
}

and here is initializing commands and prescaler i used in void main:
Code:
void main()
{   
   setup_adc_ports(AN0); 
   setup_adc(ADC_CLOCK_DIV_64);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_2(T2_DIV_BY_16,255,1);//4ms per interrupt
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_TIMER2);
   enable_interrupts(GLOBAL);
   ...
   ...
   ...

Please help me to convert this ccs code to mikro c :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top