View previous topic :: View next topic |
Author |
Message |
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Fri Mar 17, 2017 3:55 pm Post subject: GETRC with xmega128d4 |
|
|
Hi friends,
I tried to make cap. touchsensor (I use 1k 100nF like in helpfile). This working on mega328PB very good, but same code on XMEGA128D4 isn working.
Dim W As Word
Do
'the first parameter is the PIN register.
'the second parameter is the pin number the resistor/capacitor is connected to
'it could also be a variable!
W = Getrc(pind , 4)
Print W
Wait 1
W is also zero on xmega.
Has anybody a solution for this?
Cheers
Jan
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Mar 18, 2017 10:56 am Post subject: |
|
|
try to use a virtual port. (config VPORT0) _________________ Mark |
|
Back to top |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Tue Mar 21, 2017 11:03 pm Post subject: |
|
|
Have you seen my dog?
0
\___/
/\ /\
?? |
|
Back to top |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Wed Mar 22, 2017 12:13 am Post subject: |
|
|
enniom wrote: | Have you seen my dog?
0
\___/
/\ /\
?? |
żżżż |
|
Back to top |
|
|
boeseturbo
Joined: 23 Jul 2007 Posts: 46
|
Posted: Thu Mar 23, 2017 2:05 pm Post subject: |
|
|
so,
I rewrite lib.... include attachment... Than it will work (in this case for Portb)...
$lib "getRc_xmega_PINB.lib"
touch=getrc(pinB,7)
Cheers
NOTE : nice to share but notice that it is not allowed to publish the libs without prior permission. MCS will check this.
you replaced code like
Ldd r22,Z+1 ; get DDRx
with
Lds r22,DDRB ; get DDRx
that is nice but not the proper way. |
|
Back to top |
|
|
MSX
Joined: 17 Nov 2005 Posts: 5
|
Posted: Sun Apr 02, 2017 11:40 am Post subject: |
|
|
I did it "by hand":
Code: |
'Get RC-Pin
Dim RC_value as Word
Config Porta.5 = Output
Set Porta.5
Waitms 10 'charge cap
Config Porta.5 = Input
Config Xpin = Porta.5 , Outpull = Pulldown 'discharge cap
While Pina.5 = 1 And RC_value < 65534
Incr RC_value
Wend
|
Tada...RC_value has it |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Mon Apr 03, 2017 4:41 am Post subject: |
|
|
MSX wrote: | I did it "by hand":
Code: |
'Get RC-Pin
Dim RC_value as Word
Config Porta.5 = Output
Set Porta.5
Waitms 10 'charge cap
Config Porta.5 = Input
Config Xpin = Porta.5 , Outpull = Pulldown 'discharge cap
While Pina.5 = 1 And RC_value < 65534
Incr RC_value
Wend
|
Tada...RC_value has it |
???Porta.5=output y Porta.5=input???? |
|
Back to top |
|
|
MSX
Joined: 17 Nov 2005 Posts: 5
|
Posted: Tue Apr 04, 2017 8:26 am Post subject: |
|
|
Yes, right.
Porta.5 = Output to Charge the capacitor
then wait 10ms, or better 100ms
then switch the port as Input
Porta.5 = Input, and turn the avr pull-down on.
Then test how long it takes to discharge the capacitor. |
|
Back to top |
|
|
|