In addition it
would be nice to have a wiki page with the timer related registers
(Seb?).
> Nice idea. User could also register a callable called when timer reaches 0
> (or another value), or when an interrupt is raised. Having alias feature
> makes code clear.
>
>
> procedure my_proc() is
> Â Â -- bla
> end procedure
>
> alias my_proc is timerX_callable
>
You love new features, don't you ;)
Why don't you just define your code with the name timerX_callable?
This does require to include the timer library after the procedure. We
do this for i2c slave also, but I do not realy like this. I'd prefer
includes and defines at the top of the program, before any procedure
definitions.
An other thing is what my_proc() exactly is. I think you assume it is
not the isr itself, but called from the isr. This would make the isr:
if (defined(timerX_callable) == true) then
procedure timerX_isr is
pragma interrupt
if (timerXif == true) then
timerX_callable()
timerXif = false
end if
end procedure
end if
But... this would take an other stack level and more code. Would this
be worth it? We also could tell how to create the isr...
Joep
You love new features, don't you ;)
Why don't you just define your code with the name timerX_callable?
[...]
But... this would take an other stack level and more code. Would this
be worth it? Â We also could tell how to create the isr...
Hi Seb,
I think it can be done from the datasheets, to have a wiki page similar as
the SSPCON registers, so I can look for commonalityifferences of the
registers mappings throughout the various PICs
> But I could use my_proc() both in the ISR by registering it as an alias, and
> also call it from my main program.
Interesting testcase. if my_proc() has local variables or calling
parameters, the compiler will create two instances when the code is
called from both isr and main. I wonder if it does when aliasses are
used (it probably does, but worth checking).
> Stack level can be saved with "pragma
> inline". And I as a user wouldn't have to actually *think* which interrupt
> flags I need to check, not to mention I have to remember to clear this flag.
> As a ser, I just want my special procedure to be called at specific times, I
> don't want to know if it's done using interrupts or not. This is an
> implementation detail...
We agree on this. What I want to make sure is that the user does not
need to think about 2 new things, just because we want to shield 2
things. And it should give relative efficient code (no more stack
levels, no more ram uses if possible).
> And I also know this kind of construction (alias + registering within an
> interrupt) just fits my mind, the way I like to build things...
Very little fits in my mind these days, so I like as little
translation levels as possible. I have about 75 jal apps laying around
(counting jallib as one ;), so prefer to create a procedure called
timerX_callable() each time. This way I know at first glance it is
related to the timerx lib, without looking up the alias...
Joep
a.faber wrote:
> I think it can be done from the datasheets, to have a wiki page similar as
> the SSPCON registers, so I can look for commonalityifferences of the
> registers mappings throughout the various PICs
I think I can do that for you without extreme effort. The SSPCON wiki
and some others are generated from the MPLAB .dev by scripts. I can
easily select other regsiters, simply let me know which registers you
want to be shown in this future wiki.
Regards, Rob.
--
Rob Hamerling, Vianen, NL (http://www.robh.nl/)
a.faber wrote:
> registers/bits containing the text "TMR"
> registers/bits containing the text "TxCON" where x = 1..4
I thought so and have already committed a new wiki. This may not be
exactly what you want/need. If so I'll see your comments!
BTW there are PIC with more than 4 timers (e.g. 18f87K90).
a.faber wrote:
> It is already very useful, it cought already the first inconsitencies in the
> device files.
In the first place (maybe Seb can help): When I browse the Jallib.Wiki
page I don't see FindTimers.wiki, but I see it in the Source.wiki list.
Why is that? Does a wiki have to be created first from the web interface
before it can be updated via SVN?
The normalization for timer fields in the device files is currently
limited to some INTCON bits: T0IE -> TMR0IE and T0IF -> TMR0IF.
If any other normalisation is needed, please do a suggestion (an 'Issue'
seems the right place).
> When i sorted everything by * reg * I noticed that a few T0CON had different
> values which did not look correct
> When looking for example at the 18f2450,
>
> 18F2450 T0CON TMR0ON T08BIT T0CS T0SE T0PS3 T0PS2 T0PS1 T0PS0
>
>
> This matches with the device file (so wiki is genration is consistent with
> device files)
Yes (not surprisingly), the scripts for this wiki and the device files
both take the MPLAB .dev files as input and don't change any name (yet).
> var volatile byte T0CON shared at 0xFD5
> var volatile bit T0CON_TMR0ON shared at T0CON : 7
> var volatile bit T0CON_T08BIT shared at T0CON : 6
> var volatile bit T0CON_T0CS shared at T0CON : 5
> var volatile bit T0CON_T0SE shared at T0CON : 4
> var volatile bit*4 T0CON_T0PS shared at T0CON : 0
>
>
> however, the datasheet and the INC file state
(matching fields removed)
> bit 3 PSA: Timer0 Prescaler Assignment bit
>
> 1 = TImer0 prescaler is not assigned. Timer0 clock input bypasses prescaler.
>
> 0 = Timer0 prescaler is assigned. Timer0 clock input comes from prescaler
> output.
>
> bit 2-0 T0PS2:T0PS0: Timer0 Prescaler Select bits
>
(some not interesting lines removed)
> So I don't know how PSA is replaced by T0PS3 in the device file, any ideas?
Yes, this is an error in the MPLAB .dev files, which specify a 4-bit
field 'T0PS' for the 18F2420 (and probably others). I'll fix this in the
device files (and FindTimers.wiki).
I have opened an issue #82 for this defect.
> Noticed the following T0CON irregularities, have not checked if there all
> wrong
Do you mean *only* this glued-together T0PSA and T0PS fields? Or are the
other irregularities?
> Al bert
Typo or joke?
Regards, Rob,
a.faber wrote:
> Also the NT1SYNC for the 16f722 family does not seem to be correct,
>
> var volatile bit T1CON_T1SYNC at T1CON : 2
>
> T1CON_T1SYNC should be T1CON_NT1SYNC ?
>
> Looking in the inc file for 16f722 there is the NOT
> NOT_T1SYNC EQU H'0002'
>
> Looking for example to the 16f72.jal file seems to be correct
>
> var volatile bit T1CON_NT1SYNC at T1CON : 2
>
On one hand T1SYNC in the device file for the 16F722 matches its
datasheet, but NT1SYNC seems more common (abbreviation for
T1CON_NOT-T1SYNC?). So we better normalize to NTSYNC, even though it
doesn't match the datasheet for some PICs (consider it as an error in
the datasheet?).
Similarly for T3SYNC: NT3SYNC is much more common
(while T5SYNC does not occur at all, only NT5SYNC).
a.faber wrote:
> ... T2CON bit values are missing for 18f2439, 18f2539, 18f4439
Another error in MPLAB .dev files to be fixed! Will do.
a.faber wrote:
> Another one, T2CON bit values are missing for 18f2439, 18f2539, 18f4439
Now I've read chapter 12 of the datasheet of these PICs I don't think
anymore that it is an error in MPLAB (so nothing to fix).
It may be even of help to a generic timer library if the bits of T2CON
are *not* declared to determine if Timer2 is available.
Regards, Rob
a.faber wrote:
> But why is the T2CON reg still defined? Isn't better to remove the T2CON reg
> definition afterall if there is not Timer2 present?
Don't ask me! Ask Microchip (or read the datasheet).
I just 'copy' what is in the MPLAB .dev files (and make some
corrections) without asking why ;-)
Of course I could remove Timer2 registers from the device files of these
PICs, but is that the right thing to do? Timer2 is present, but
according to the datasheet not supposed to be touched, but also not
absolutely forbidden to be touched!
Regards, Rob.
a.faber wrote:
> About halve of T2CON-T2OUTPS3 is defined as T2OUTPS3, while the other halve
> is defined as using TOUTPS3
> (same for other OUTPS registers)
>
>
> The majority of T4CON-T4OUTPS3 is defined as, while the following devices
> are using TOUTPS3
>
>
> 18F6527 T4CON - TOUTPS3
(etc)
The datasheet specifies T4OUTPS3..(etc). So it seems an error in MPLAB
.dev files. We could normalize in two ways:
* Leave out the timer number for all Timers
(no conflict because we use the TxCON prefix)
* Insert the number to be consistent over the whole range
(and obey the datasheet).
Personally I like the first option most, but "the datasheet is the boss"
so I think it will become inserting the timer number where it is missing.
BTW I've seen that some field names are truncated in
FindTimerControl.wiki (e.g. of 18f86K22 line of T10CON and T12CON). I'll
repair that.
a.faber wrote:
> Agree with your proposal,
>> * Insert the number to be consistent over the whole range
>> (and obey the datasheet).
Well, it is somewhat more complicated:
- Is the number-insert also needed for the midrange PICs?
(will apply to Timer2 only: conflict with the datasheet)
- Is the number insert also needed for Timer2 of the 18Fs?
(might conflict with the datasheets, but I didn't check all)
> it would be nice if you can send me, after the
> changes, the "old" WIKI file by mail, since I've created an excel sheet with
> some analysis function to spot the differences.
What is 'old'? Do you mean the one with the TMR registers?
I need your opinion/vote about proposed changes in device files for the
timer library Albert is designing. There are a number of inconsistencies
in MPLAB for the naming of some bit fields in timer control registers.
You can read it back in the Jallib, but to summarize:
1. Rename 'T1SYNC' of T1CON to 'NT1SYNC' for the 16F72x.
Later we found also that a number 18Fs have T1SYNC, T3SYNC
which should better be NT1SYNC and NT3SYNC for consistency
even though the datasheet specifies T1SYNC (with an overscore
to indicated 'not').
2. For many (18F) PICs the T2OUTPS field of T2CON is declared as
T2OUTPS. For some PICS it is declared as TOUTPS, while the
datasheets specify T2OUTPS. Since the datasheet prevails I
proposed to correct this deviation:
rename TOUTPS to T2OUTPS for T2CON
more generally rename TOUTPS of TxCON to TxOUTPS
(for PICs with more timers).
But the midrange PICS have only one Timer with TOUTPS field
(Timer2) and the datasheets seem consistently calling it TOUTPS.
> (etc)
>
> The datasheet specifies T4OUTPS3..(etc). So it seems an error in
> MPLAB .dev files. We could normalize in two ways: * Leave out the
> timer number for all Timers (no conflict because we use the TxCON
> prefix) * Insert the number to be consistent over the whole range
> (and obey the datasheet). Personally I like the first option most,
> but "the datasheet is the boss" so I think it will become inserting
> the timer number where it is missing.
Hi Guys,
I appreciate your opinion/vote about proposed changes in device files
for the timer library Albert is designing. There are a number of
inconsistencies in MPLAB for the naming of some bit fields in timer
control registers.
You can read it back in the Jallib, but to summarize:
1. Rename 'T1SYNC' of T1CON to 'NT1SYNC' for the 16F72x.
Later we found also that a number 18Fs have T1SYNC, T3SYNC
which should better be NT1SYNC and NT3SYNC for consistency
even when the datasheet specifies T1SYNC (with an overscore
to indicated 'not').
2. For many (18F) PICs the T2OUTPS field of T2CON is declared as
T2OUTPS. For some PICS it is declared as TOUTPS, while the
datasheets specify T2OUTPS. Since the datasheet prevails I
proposed to correct this deviation:
rename TOUTPS to T2OUTPS for T2CON
more generally rename TOUTPS of TxCON to TxOUTPS
(x any number, for PICs with more of such timers).
But the midrange PICS have only one Timer with TOUTPS field
(Timer2) and the datasheets seem consistently calling it TOUTPS.
So if we normalize to T2SYNC for consistence it is in conflict
with the datasheet.
Questions:
1. Do we vote for NT1SYNC (item 1 above)?
2. Do we vote for consistent TxOUTPS for the 18Fs?
3. Do we vote for T2OUTPS for the baseline PICs?
If you don't care Albert is free to find a solution for the timer
library and I'll make the necessary adjustments in the device files.
Rob Hamerling wrote:
> 1. Do we vote for NT1SYNC (item 1 above)?
> 2. Do we vote for consistent TxOUTPS for the 18Fs?
> 3. Do we vote for T2OUTPS for the baseline PICs?
For the FindTimerControl wiki I have assumed the following answers:
1: yes, 2: yes, 3: no (T2CON_TOUTPS remains unchanged).
The dev2jal script is changed accordingly, but can easily be changed to
whatever the Jallib community decides.
I'll update TimerControl.wiki and send you personally a special edition
(with TMR registers).