AlGeorge
Member level 1
- Joined
- Nov 17, 2009
- Messages
- 39
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Waihi Beach
- Activity points
- 1,606
Tks; but had allowed for that in 'changing the offset' above.daviddlc said:You didn't mention the PIC model, but for some of them you need to consider the next: (From the spec document):
"If the TMRX register is written to, the increment is inhibited for the following two instruction cycles. The user can work around this by writing an adjusted value to the TMRX register"
Thanks I'd missed your reply. I'm using a development board with 16F690 which has an internal xtal 32.768KHz Osc.betwixt said:You still haven't mentioned which PIC you are using. Your calculation looks correct though, at least from a functional point of view although it's difficult to predict what extra code your compiler is adding.
Some PICs have an internal oscillator which runs at 31KHz, is it possible you are using that instead of your crystal? It caught me out once with a real-time clock that lost time at an alarming rate. the clue was that it still worked when I removed the
crystal!
Brian.
Crikey Brian, what are Microchip doing - they claim it does have an internal 32.768KHz xtal osc. Why should they do this, especially giving an erroneous frequency? If that is indicative of their product, maybe I'd be better looking to Atmel. 31khz would make sense given the anomaly experiencing here. Can you perchance let me know where you got this info?betwixt said:I think you are right. On most PICs you can use two separate oscillators, one for the main clock and T1's own oscillator for other purposes, the '690 doesn't allow you to do that, probably because of the low pin count.
Regardless of the oscillator source, your calculation is still based on a 32768Hz clock which is wrong. The internal oscillator is NOT crystal controlled, it is laser trimmed to be a fairly accurate 31000Hz. So you have two choices, either adjust your calculation so you use 31KHz instead of 32.768KHz or use a higher frequency main clock and divide it using the internal timers and interrupts.
Brian.
I hate being beaten by logic, but the PIC16f690 dev board has got me beat. Ive done all the calculations correctly, and the jolly thing is nowhere near 31khz. Its much lower around 25khz. I've been there before, and never had this amount of trouble with micros. Atmel is starting to sound more attractive!betwixt said:Page 47 of the data sheet (41262E.pdf) !
I'm only guessing but Microchip might deliberately have made LFINTOSC 31KHz instead of 32KHz to stop people using it as a real-time clock source, it avoids all the complaints if it isn't accurate enough!
Brian.
Hi yes I got ur PM and thought I had sent u the code but dont recall a reply. Its not important now though, as I've sussed out most of whats going on.betwixt said:Only the 10F, 12F and 16F use the banked memory system, the other flavors are linear and easier to visualize. The is a big advantage in banking though, it lets you access any register or RAM address with the contents of any other register. In a chip where the instruction set allows almost any source and destination for operations it makes for very efficient code usage.
I'm glad you sorted out the oscillator problem. I did PM you with some suggestions a while back which I hope were useful.
Brian.
Hi Brian. Still did not get the code. Hope you have had an excellent Christmas. Cheers,betwixt said:I didn't actually provide you with code but several suggestions to make it more accurate and fix your 15 hour day problem! I'll dig the original out of the archive and send it again tomorrow.
Brian.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?