Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

GETRC with xmega128d4

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

Bascom Member



Joined: 23 Jul 2007
Posts: 46

blank.gif
PostPosted: Fri Mar 17, 2017 3:55 pm    Post subject: GETRC with xmega128d4 Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Sat Mar 18, 2017 10:56 am    Post subject: Reply with quote

try to use a virtual port. (config VPORT0)
_________________
Mark
Back to top
View user's profile Visit poster's website
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 46

blank.gif
PostPosted: Tue Mar 21, 2017 1:07 pm    Post subject: Reply with quote

Hi Mark,

can you send me a sample?

I tried this and have no luck with it Sad


Code:


dim temp as word


Config VPort0 = C

do
temp=getrc(Pin0,7)
print temp
loop
end

 


Cheers
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Tue Mar 21, 2017 11:03 pm    Post subject: Reply with quote

Have you seen my dog?

0
\___/
/\ /\

??
Back to top
View user's profile
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 46

blank.gif
PostPosted: Wed Mar 22, 2017 12:13 am    Post subject: Reply with quote

enniom wrote:
Have you seen my dog?

0
\___/
/\ /\

??


żżżż
Back to top
View user's profile
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 46

blank.gif
PostPosted: Thu Mar 23, 2017 2:05 pm    Post subject: Reply with quote

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
View user's profile
MSX

Bascom Member



Joined: 17 Nov 2005
Posts: 5

germany.gif
PostPosted: Sun Apr 02, 2017 11:40 am    Post subject: Reply with quote

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
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Apr 03, 2017 4:41 am    Post subject: Reply with quote

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
View user's profile
MSX

Bascom Member



Joined: 17 Nov 2005
Posts: 5

germany.gif
PostPosted: Tue Apr 04, 2017 8:26 am    Post subject: Reply with quote

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
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