Jump to content
Sign in to follow this  
amohr

fairly desperate help with Timer1

Recommended Posts

so I have a function which initializes Timer1.

 

in my main I do the following:

intcon = 0;

pie1 = 0;

pir1 = 0;

 

adcon0 = 0;

   adcon1 = 6;   // Set PortA to Digital I/O

trisa = 0;   // PORTA to all output

trisb = 0;

trisc = 10100000b;

trisd = 0;     // PORTD to all output

t1con = 00110000b;   // tmr1 - 1:8 prescale, internal clock, turn off

option_reg = 0;             // portb pull-ups + tmr0 on clkout

set_bit(intcon, PEIE);     // PEripherial Interrupt Enable (need for any pie1 interrupt)

   set_bit(intcon, GIE);       // Enable Global Interrupts

 

 

followed by calling a function which does the following:

clear_bit(intcon, GIE);

clear_bit(t1con, TMR1ON);

tmr1l = 0;

tmr1h = 0x0b;

tmr1l = 0xdc;

clear_bit(pir1, TMR1IF);  // clear TMR1 overflow flag

set_bit(pie1, TMR1IE);    // enable TMR1 overflow interrupt

set_bit(intcon, GIE);

set_bit(t1con, TMR1ON);

 

while(1) nop();

 

in the debugger i see TMR0 incrementing, intcon is 196, pie1 is 1, TMR1L is 220, TMR1H is 11, and T1CON is 49 as expeted, but TMR1 never decrements!  It's driving me nuts!  (doesn't increment in debugger or on hardware)

 

anyone have any ideas?

Share this post


Link to post
Share on other sites

The simulator currently simulates:

Instruction decoding, ALU, W REG, STATUS register, Program counter, FSR register, RAM File Registers, Stack, TMR0

and EEPROM.

 

So you will see no activity from timer 2 in the simulator.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...