declaring word-size variables in definitionfiles

Discuss about beta versions of mikroPascal compiler.
Post Reply
Author
Message
jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

declaring word-size variables in definitionfiles

#1 Post by jpc » 01 Nov 2006 19:46

while working on timer-programmation ( PIC P18 ) i found several timers ( there can be other registers ) allowing for 16bit acces ( e.g. TMR1) in the TxCON register. It would be practical to have those declared already in the definition file. I added to mysource now

Code: Select all

 var TMR1        : word;absolute 0x0FCE; volatile; register;
which is the address of the TMR1L for this 18F452. The request would thus be to add word ( or whatever )sized variables to the definition-files for those that can be accessed as such ( successive byte's) I have not checked if this timer has the same address for all P18 chips , actually do not want to check for absolute addresses if i change PIC .
Last edited by jpc on 02 Nov 2006 09:43, edited 1 time in total.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: decalring word-size variables in definitionfiles

#2 Post by zristic » 02 Nov 2006 09:23

This is a very nice idea, we will certanly work on it in the future. Thanks.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#3 Post by jpc » 02 Nov 2006 14:39

argh ! not such a good idea at all ! After spending many hours in an attempt to improve my interrupt-driven soft-uart i finally had a good look at the datasheet :
11.5 Timer1 16-Bit Read/Write Mode
Timer1 can be configured for 16-bit reads and writes
(see Figure 11-2). When the RD16 control bit
(T1CON<7>) is set, the address for TMR1H is mapped
to a buffer register for the high byte of Timer1. A read
from TMR1L will load the contents of the high byte of
Timer1 into the Timer1 high byte buffer. This provides
the user with the ability to accurately read all 16-bits of
Timer1 without having to determine whether a read of
the high byte followed by a read of the low byte is valid,
due to a rollover between reads.
A write to the high byte of Timer1 must also take place
through the TMR1H buffer register. Timer1 high byte is
updated with the contents of TMR1H when a write
occurs to TMR1L.
This allows a user to write all 16 bits
to both the high and low bytes of Timer1 at once.
The high byte of Timer1 is not directly readable or writable
in this mode. All reads and writes must take place
through the Timer1 high byte buffer register. Writes to
TMR1H do not clear the Timer1 prescaler. The
prescaler is only cleared on writes to TMR1L.
Using the TMR1 as i proposed writes the low byte first and the timer is not well initialised !

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#4 Post by zristic » 02 Nov 2006 15:15

Yes, but that is only if you enabled 16 bit write mode.

Post Reply

Return to “mikroPascal Beta testing”