![]() |
Re: quick question: TIMERS
I just relized something. In the initialize routines for the timers, the first 2 lines are address setters (I think). Most of mine are 0x00! Does this make a difference?
|
Re: quick question: TIMERS
Quote:
Believe I found the problem. TICKS is declared as char (-127 to 127) You are checking for 255 as an overflow. TIME will never increment. I grabbed Kevins interrupt code and added your code to the interrupt handler. Only difference is I just declared your globals as static just within interrupts.c for my ease of duplicating your results. TICKS and AUTOCLOCK increment as you wanted. In Initialize_Timer_1 I changed: Code:
PIE1bits.TMR1IE = 1; |
Re: quick question: TIMERS
before i enable one of those timers, is there anythign i should know about which one would work best are there significant differences for them, i noticed you can change the ammount of time each tick increses the clock by.
once i enable one im still confused as far as the state switches and the case statements, idon't understand how the whole thing works is there any documentation or sample code i can look through, im really stumped and i would like to get a timer working. |
Re: quick question: TIMERS
OK...I really want to help you dude but it seems like you don't understand what we're trying to say each time, or I can't explain it well enough...why don't you IM me (sn: TenintheCrunch)? I think I'll be able to help you more talking directly :)
Cheers, |
Re: quick question: TIMERS
I changed a compiler option to assume Char is unsigned. I only use a signed char one place, -1 - 1, and it's declared as signed. I also sent TICK to dashboard, and it didn't work. I didn't have IE set to 1, but I didn't think it would make a difference (it would just be slower, right?)
|
Re: quick question: TIMERS
Where's the option for making chars unsigned by default? Does that affect ints and longs as well?
|
Re: quick question: TIMERS
Quote:
Project->Build Options...->Project under tab "MPLAB C18" There is a quick radio button for treating "char" as unsigned and one for forcing all calculations to be performed at least as int rather than the smallest type included in the calculation. You can also enter your own flags by clicking on "Use Alternate Settings" and typing into the box that becomes enabled. You'll find the available compiler flags documented in the MPLAB C18 C Compiler User's Guide that came on the MPLAB installation CD, Appendix C. e.g., -k is the flag for treating char as unsigned. When you click on the radio button you'll see "-k" appear in the "Inherit global settings" window. |
Re: quick question: TIMERS
Quote:
INTCON3bits.INT2IE = 1; Yes, this is required. It's your on/off switch for individual interrupts. It enables the interrupt which is disabled by default. Otherwise, nothing will happen. |
Re: quick question: TIMERS
Banner interupts work, but not timers.
|
Re: quick question: TIMERS
Quote:
Code:
PIE1bits.TMR1IE = 1; |
Re: quick question: TIMERS
i got my ded reckoning worked out and i have a switch wired up to switch between the two modes how would i do that using case statements?
it should be something like case1 if (rc_dig_in_10=1) {auton 1} case2 else(rc_dig_in10=0) {auton 2} i read about them but how would they be used to work with a digital input from the rc |
Re: quick question: TIMERS
Quote:
Code:
if (rc_dig_in_10 == 1) //or just "if (rc_dig_in_10)" |
Re: quick question: TIMERS
Quote:
|
Re: quick question: TIMERS
Quote:
If you try it and it doesn't behave as you expect post the error here and we'll help you debug any problems. |
Re: quick question: TIMERS
Quote:
When you enter autonomous mode, all inputs are reset to neutral, so you have to capture the value from rc_dig_in_10 before autonomous turns on. Create a prevRcDigIn10 variable, and set that equal to the current one at the end of every loop (right before putdata()), then when you move into autonomous, look at that previous varialbe, not the real one (the "real" one will always be zero). |
| All times are GMT -5. The time now is 12:47. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi