View previous topic :: View next topic |
Author |
Message |
Emmetb
Joined: 08 Nov 2013 Posts: 18
|
Posted: Mon Nov 11, 2013 7:50 pm Post subject: Xmega buttons and noises |
|
|
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 |
|
|
Emmetb
Joined: 08 Nov 2013 Posts: 18
|
Posted: Wed Nov 13, 2013 1:35 am Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Wed Nov 13, 2013 10:29 am Post subject: |
|
|
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 |
|
|
Emmetb
Joined: 08 Nov 2013 Posts: 18
|
Posted: Wed Nov 13, 2013 12:49 pm Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Wed Nov 13, 2013 11:23 pm Post subject: |
|
|
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 |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Thu Nov 14, 2013 10:15 pm Post subject: |
|
|
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 |
|
|
Askjerry
Joined: 06 May 2004 Posts: 20 Location: Austin, Texas
|
Posted: Sat Feb 22, 2014 8:04 pm Post subject: |
|
|
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 |
|
|
|