Go to Post You know you're addicted to FIRST when robots are sexy! - Pat Arnold [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 09-03-2006, 22:30
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Timer0 stubbornly not working

Hey all,

I'm embarrassed to have to ask, but we're using Timer0 in our code to give us a 60Hz cycle on a PID loop. And the darned thing refuses to work. After an hour or troubleshooting and fiddling with code and looking at a frequency counter, we were stuck at about 38.somethingHz. I finally realized that this was a full count from 0 to 65535 at a prescale of 1:4. So our pre-load values aren't pre-loading properly. Here's a code snippet of the initializing and the interrupt handler:

Code:
//Initialize
  T0CON= 0b00000001;    ////1:4 Prescale
  TMR0H= 0X5D;   //Pre-load TMR0 to overflow at 60 Hz
  TMR0L= 0X3D;
  T0CONbits.TMR0ON= 1; //Turn timer on

  T1CON= 0b10000110;  //Set Timer 3 in async counter mode, 16-bit read
  TMR1H=0x00;
  TMR1L=0x00;
  T1CONbits.TMR1ON = 1;  //Turn Timer on


//Interrupt handler
    else if (INTCONbits.TMR0IF && INTCONbits.TMR0IE) // timer 1 interrupt?
    {

		INTCONbits.TMR0IF = 0; // clear the timer 0 interrupt flag
		TMR0H = 0X5D;   //Pre-load TMR0 to overflow at 60Hz
		TMR0L = 0X3D;
		Timer1L = TMR1L;
		Timer1H = TMR1H;
		TMR1H = 0x00;
		TMR1L = 0x00;
		fMainTimer = 1;
    }
We've got a similar problem with Timer1. We're using it as an asyncronous counter in 16-bit read/write mode. Unfortunately, the high byte just isn't getting read. Timer1H is always equal to zero, even when it shouldn't be. We've tried using it not in 16-bit read/write mode, and it works fine. But then we have to worry about getting incorrect readings if the low byte overflows as we're reading.

I'll note that the commonality here is the Timer0 exclusively uses 16-bit read/write mode, and Timer1 wasn't working in 16-bit read/write mode. So. Does anyone know if there's some extra step I need to take to get things to work in 16-bit read/write mode? Is it just broken? Is there PIC errata about this too? Will I ever stop ending my sentences in question marks?
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Camera isn't working Idaman323 Programming 13 15-02-2006 23:18
What I'm Working On Jared Russell Programming 2 18-01-2006 02:34
CMUCam not working Inverted Programming 10 04-02-2005 19:32
IR Beacon/reciever not working... still... Ferazel2001 Programming 23 04-02-2004 23:30
I'm working :) Jack FIRST Scouting Network 2 03-01-2004 01:26


All times are GMT -5. The time now is 03:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi