Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Attiny 417 output failure
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat Dec 04, 2021 6:48 pm    Post subject: Re: Attiny 417 output failure Reply with quote

nobner wrote:
finally i found the solution:
It is the name of the variable "RED_PAU".

Which is truly nonsense.
Quote:
When i replace it with some other name (like "nonsense", or any other name), programm works bug-free.

I've compiled two - except different names RED_PAU & nonsense - otherwise identical versions of your code, the resulting hex-files were identical included the last byte.

Alas you did not tell the truth.
If you had posted not shreds but complete code, one would have been able to notice that you not only replace, but instead you've additionally dim'd a new variable called "nonsense".
And this in fact did the trick.

You did not read the help:
Quote:
GETADC
Syntax Xtiny
var = GETADC()
var = GETADC(channel)
var = GETADC(ADC , channel)

Var
The variable that is assigned with the A/D value. This should be a Word or other 16 bit variable.

It was simply a memory overrun, the high byte of GetADC for white overwrote Red_PAU.

The additionally dim'd "nonsense" was unaffected, because RED_PAU acted as buffer and made you believe the name-giving was the culprit.
Dimension all ADC-values as Word or integer as required and you're good.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Sun Dec 05, 2021 1:15 pm    Post subject: Reply with quote

for normal AVR the data type is not important but for xmega/xtiny it has to be a word/integer because the target variable is assigned using a pointer.
i will add a warning.

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

Bascom Member



Joined: 29 Apr 2015
Posts: 21

germany.gif
PostPosted: Fri Dec 10, 2021 4:30 pm    Post subject: Attiny 417 output failure Reply with quote

@MWS: Yes, you are right, now RED_PAU works also - thank's for explanation.
I didn't realize, that using "word"-variables is necessary, although i'm using the ADC in 8-bit mode.
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
Goto page Previous  1, 2
Page 2 of 2

 
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