Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Xmega buttons and noises

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
Emmetb

Bascom Member



Joined: 08 Nov 2013
Posts: 18

blank.gif
PostPosted: Mon Nov 11, 2013 7:50 pm    Post subject: Xmega buttons and noises Reply with quote

So i attached buttons, configured portc and its reacting even when i close hand to button, no pushing them, no debounce helping.
I dont know how to configure them i think. Buttons to GND.
How should i write port configuration code??
Buttons on PortC 0-7.
I tried config out-in pulldown up and nothing worked properly.

(BASCOM-AVR version : 9.8 , Latest : 2.0.7.6 )
Back to top
View user's profile
Emmetb

Bascom Member



Joined: 08 Nov 2013
Posts: 18

blank.gif
PostPosted: Wed Nov 13, 2013 1:35 am    Post subject: Reply with quote

Problem seems like not existing when i use asm, same with bas making problem with random pulses like buttons were pushed.
Code:

LDI R16, &B11111111 'setting var of pullups or to pin states
OUT DDRC, R16         'pullups as in R16
OUT PORTC, R16        'pins states as in R16

we can of course set/reset single pins by "SBI/CBI PORTC, x"
 
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Wed Nov 13, 2013 10:29 am    Post subject: Reply with quote

you do not show any code, you use an ancient version. i would advise to update.
then it is also good to know that config port/pin also sets the DDR register.
when you make the port register high, it will create a pull up in normal avr chips but not in xmega.
xmega has a special register for this. so it is amazing that it works for you.
you need to use the pinctrl register to set the pin in pullup mode. config xpin does this on a pin or group.

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

Bascom Member



Joined: 08 Nov 2013
Posts: 18

blank.gif
PostPosted: Wed Nov 13, 2013 12:49 pm    Post subject: Reply with quote

How do i set many pins to pullup and down in one line code in bas?
Oh, and its not about it working but about it doesnt make buttons collect all electromagnetic and bounce without even touching them,
like in bas code.
I have no idea why.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Wed Nov 13, 2013 11:23 pm    Post subject: Reply with quote

you do not show any bascom code. So i have no idea what you do.
You use a very old version which is not a good idea with xmega.
The usual way is http://avrhelp.mcselec.com/ config xpin. But that will only work with a more recent version of the compiler.

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

Bascom Member



Joined: 11 Aug 2004
Posts: 948
Location: the Netherlands

netherlands.gif
PostPosted: Thu Nov 14, 2013 10:15 pm    Post subject: Reply with quote

If the software thinks that a button is pressed when it is not but only you hand is nearby the button i recommend to take a look at the hardware.
Back to top
View user's profile
Askjerry

Bascom Member



Joined: 06 May 2004
Posts: 20
Location: Austin, Texas

usa.gif
PostPosted: Sat Feb 22, 2014 8:04 pm    Post subject: Reply with quote

The problem is likely the way you have your button or switch wired.
I like to use external components on the buttons/switches to make sure they are properly going to function...



This is the incorrect way to connect a button... when not pressed it has no reference and can be set off by any stray RF fields, etc.



This is better... but if someone sets the pin as an output, and it is LOGIC 0... when someone pressed it, the pin will draw a great amount of current and the pin will be damaged.



By doing this... the pin is protected, and false triggers are avoided. You may still need to denounce the switch... but just bringing your hand nearby won't set it off.

This was taken from my tracked robot project... something I still need to finish. :-/

Hoe that helps,
Jerry
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions 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