Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

XTINY 414 TCA Timer

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
nobner

Bascom Member



Joined: 29 Apr 2015
Posts: 19

germany.gif
PostPosted: Thu Jul 29, 2021 4:10 pm    Post subject: XTINY 414 TCA Timer Reply with quote

Hello to all,
i'm trying the XTINY414 for the first time - struggling with a simple thing.

I want to put the timer value to a variable. With the Attiny's i did this "variable = timer1".

With the Xtiny i get: Error : 93 Line : 28 Variable not dimensioned [TCA0] ,

What i'm doing wrong?


Code:

'RGBW Treiberplatine 10W
'ATTINY414
'Norbert Nestler
'V01 19.07.2021
'Fuses:
'Programmierung UPDI (PIN10)

$Regfile="atxtiny414.dat"
$Crystal=20000000
$hwstack=40
$swstack=16
$framesize=32

config Sysclock = 16_20mhz , Prescale = 1 , Clockout = Disabled

config TCA0 = NORMAL , PRESCALE = 1 , RESOLUTION = NORMAL , RUN = ON

disable interrupts

DIM RED_EIN as word  'Low Phase Eingangssignal, Leuchte AN, Controllereingang HIGH

START TCA0

do

RED_EIN = TCA0

loop

end
 


(BASCOM-AVR version : 2.0.8.4 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5307
Location: Holland

blank.gif
PostPosted: Thu Jul 29, 2021 6:37 pm    Post subject: Reply with quote

in the normal AVR timers were similar, well at least at the begin. It made some sense to have an alias.
but now there are different timers and different names. For Xtiny there is no alias to a short timer name. But there is of course one for the word register
So you need to use : TCA0_CNT register which is a word alias for the timer.
If you prefer TCA0 , you could also add an entry for that

you best read the Xtiny topic from the help.
most hardware is compatible. only timers are more similar to xmega timers.

_________________
Mark
Back to top
View user's profile Visit poster's website
nobner

Bascom Member



Joined: 29 Apr 2015
Posts: 19

germany.gif
PostPosted: Fri Jul 30, 2021 8:07 am    Post subject: XTINY 414 TCA Timer Reply with quote

Dear Mark,
thank you for your information.

I read the help file for the XTiny's before (placed in the section "chips"), but to timer topic i found only: "Timer TCA has 1 or more wave outputs. As a user you need to set the pin to the output mode."
Is there another help file for the XTiny's i didn't see?

Using your hint, should this code work?
RED_EIN = TCA0_CNT register

What did you mean with: "If you prefer TCA0 , you could also add an entry for that"
Sorry for asking, but i didn't use this before.
A little sample would be very helpful.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5307
Location: Holland

blank.gif
PostPosted: Fri Jul 30, 2021 9:50 am    Post subject: Reply with quote

there is not other xtiny help.


In normal AVR processors the timers had an alias to the counter register named TIMER0, TIMER1 , etc.
Thus TIMER1 would access TIMER1 registers TCNT1L and TCNT1H.

In the Xtiny, megaX. AVRX these aliases do not exist. There is however an alias to access word registers like a word.
You can find these aliases in the DAT file under the [WIO] section.
For TCA0 you will find :
- TCA0_CNT the timer counter register
- TCA0_PER the period register
- TCA0_CMP0 the compare 0 register
- TCA0_CMP1 the compare 1 register
- TCA0_CMP2 the compare 2 register

All relevant registers that form a word register like :
TCA0_CNTL=2592 ; 0A20 byte alias LSB see WIO
TCA0_CNTH=2593 ; 0A21 byte alias MSB see WIO
Will have an entry under the WIO section.
This is simply the name without the L/H
And the address is always the low register address.
Because the name is under the WIO section the variable/register will be treated as a 16 bit word. The correct read/write order will be used by the compiler which is different for AVR/XMEGA/XTINY

When you like to use your own definition or alias you could add an alias. Just take care that an update will replace the DAT files.
For example if you like TIMER1 or TCA0 you can add it to the WIO section like this :
TCA0_CNT=2592 ; 0A20 word ## EXISTING ENTRY
TCA0 = 2592 ; NEW ENTRY



RED_EIN = TCA0_CNT ' this will read the TCA0_CNT register which is RED_EIN = TCA0_CNTL and TCA0_CNTH


under samples\xtiny you find some timer examples.

_________________
Mark
Back to top
View user's profile Visit poster's website
nobner

Bascom Member



Joined: 29 Apr 2015
Posts: 19

germany.gif
PostPosted: Fri Jul 30, 2021 2:24 pm    Post subject: XTINY 414 TCA Timer Reply with quote

Dear Mark,
now it's clear for me what to do.
Thanks for this good support!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum