CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with timer 1 in PIC18F2450

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
marceleza



Joined: 24 May 2006
Posts: 6
Location: S㯠Paulo - Brazil

View user's profile Send private message

Problem with timer 1 in PIC18F2450
PostPosted: Mon Dec 14, 2009 10:48 am     Reply with quote

Hello!

I made this code:
Code:

#INCLUDE <18F2450.h>

//#fuses HS,NOWDT,NOPUT,NOPROTECT,BROWNOUT,BORV43,MCLR,NODEBUG,NOLVP,NOUSBDIV
#FUSES NOWDT                   
#FUSES WDT128                   
#FUSES HSPLL                   
#FUSES NOPROTECT               
#FUSES NOBROWNOUT               
#FUSES BORV20                   
#FUSES PUT                     
#FUSES NOVREGEN                   
#FUSES STVREN                   
#FUSES NODEBUG                   
#FUSES NOLVP                     
#FUSES NOWRT                   
#FUSES NOLPT1OSC                   
#FUSES IESO                     
#FUSES FCMEN                   
#FUSES NOPBADEN               
#FUSES BBSIZ2K                 
#FUSES NOWRTC,NOWRTB,NOEBTR,NOEBTRB,NOCPB,MCLR,NOXINST,PLL3,NOUSBDIV,CPUDIV2                 

#device adc=10                                          // ad 10 bits
#use delay(clock=10000000)
#zero_ram 

#int_timer1
void espera(void);

VOID main()
{
   setup_oscillator(OSC_STATE_EXT_RUNNING);     //
   setup_adc_ports (AN0_TO_AN2);                        //
   setup_adc (ADC_CLOCK_DIV_8);                        //
   setup_ccp1 (ccp_off);      //ccp desligado
                             
   setup_timer_0 (rtcc_div_2 | rtcc_8_bit | rtcc_internal );   //tempo de 204us era rtcc div2

   setup_timer_1 (T1_DIV_BY_1  | T1_internal );                 

   set_timer0 (0);     
 //  set_timer1 (0);                                   
   disable_interrupts(int_timer0);                       
   enable_interrupts(INT_TIMER1);                       
   disable_interrupts(int_ext);                         
   disable_interrupts(int_rb);     
   disable_interrupts(INT_rda);                       

   EXT_INT_EDGE(H_TO_L);

#INT_TIMER1    // tempo de duracao das telas
void espera()     //
{     
      byte    temp;
      temp++;
}


But the timer don´t work in mpsim. I am using the mplab 8.33 and ccs 4.064.

The timer count only in 8 bits, don't generate the overflow!

Thanks
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Dec 14, 2009 11:20 am     Reply with quote

Try adding:

enable_interrupts(GLOBAL);

If global is not enabled then NO interrupt will happen.

Ronald
Ttelmah
Guest







PostPosted: Mon Dec 14, 2009 11:40 am     Reply with quote

Also, on not seeing 16bts in use, CCS sets up the timer to operate in 16bit R/W mode. To 'see' the top byte update, you have to perform a read from the low byte, which then latches the high byte value into the top byte. Generally you will need to add an instruction to your code, to read the low byte, before the simulator will update the high byte.

Best Wishes
marceleza



Joined: 24 May 2006
Posts: 6
Location: S㯠Paulo - Brazil

View user's profile Send private message

PostPosted: Mon Dec 14, 2009 12:17 pm     Reply with quote

ok, thanks for the answer, but I don't understand how to do this.

In real operation (pic in board), the counter will work?

best regards

marcelo
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group