BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:53 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: ARC-32 Performance Difference BASIC vs ASM
PostPosted: Wed Jul 27, 2011 12:35 pm 
Offline
Citizen
User avatar

Joined: Thu Feb 17, 2011 3:17 pm
Posts: 18
Yea, thats exactly right :D. I plan to have 28 Servo Outputs, 2 Analog Inputs, 6 Digital Inputs, and 1 Digital Output, which I think fills up the boards I/O capabilities on all headers.

That sounds great if the HSERVO subsystem automatically takes care of inputs on those pins, and if it's anything like the setup for controlling the servos then that should just drop right into my project :D. Am I right in thinking that the complete HSERVOSTATE function works on all input pins? I know in Basic it can be used to read the battery voltage, but will it work on the I/Os on the AUX 2 header?

One final thing, for the 1 digital output I need, is that simply a case of setting an I/O pin to output and sending highs and lows, or does HSERVO have management for this too?

Thanks,
-1


Top
 Profile  
 
 Post subject: Re: ARC-32 Performance Difference BASIC vs ASM
PostPosted: Wed Jul 27, 2011 2:09 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Yep it sounds like you are pretty well maxing it out!

HServostate is only on some pins like, which are marked in the Arc32 data sheet. I think they are: 9-15,24-31.

I don't believe that any of the IO pins on AUX2 are analog capable. There is one on the Aux1 which can be used for Analog input.

Hservo subsystem does not take care of setting an IO pin high or low. But this is not difficult.

I don't know if Nathan has uploaded his set of macros up here in this forum or not, He did earlier on the Lynxmotion forums. They make it easier to do lots of the things like setting a pin to be an Input pin or an Output pin or High or Low... There is more information about this up in the thread: http://www.lynxmotion.net/viewtopic.php ... bly+macros

There are ones like:
Code:
;********************************
;       HighFuncMac
;********************************
;R0L = Pin number
;********************************
.macro _HIGHFUNCMAC                     ;(46)
      _GETPINMAC                     ;18
      bset      r3l,@er2            ;8 Set PDR bit
      mov.b      @(0x70-0xD0,er2),r1l   ;6 Get PCRS value
      bset      r3l,r1l               ;2 Set PCR bit
      mov.b      r1l,@(0x70-0xD0,er2)   ;6 Save PCRS
      mov.b      r1l,@(0x10,er2)         ;6 Set PCR
   .endm     
         
;********************************
;       HighFastFuncMac
;********************************
;R0L = Pin number
;********************************
.macro _HIGHFASTFUNCMAC                  ;(26)
      _GETPINMAC                     ;18
      bset      r3l,@er2            ;8
   .endm

You simply need to put your desired IO pin in R0L the macro does the rest. You can include the macro file or you can simply copy the macros into your code. Note: These will not work on all Arc32 IO pins, that it only those that are marked as standard IO pins in the data sheet.

Note: the two macros I show above require other macros as well. The difference between the two macros for setting a pin high is one makes sure to set the IO pin to be an output pin, where the other one assumes that you already did this.

Good Luck
Kurt


Attachments:
Bap Assembly Macros.zip [1.62 KiB]
Downloaded 26 times
Top
 Profile  
 
 Post subject: Re: ARC-32 Performance Difference BASIC vs ASM
PostPosted: Thu Jul 28, 2011 12:24 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Just to clarify, since Kurt already covered most of it, hservostate works with all 32 servo pins, however only analog capable pins will return analog values. The digital only pins will return 0 or 1023 only.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: ARC-32 Performance Difference BASIC vs ASM
PostPosted: Thu Jul 28, 2011 2:12 pm 
Offline
Citizen
User avatar

Joined: Thu Feb 17, 2011 3:17 pm
Posts: 18
Cheers for the reply. I have to say I didn't know that you could do macros, so thats cool :). One think i'm not clear on from looking through the examples, is how you actually read analog values from the servo pins, or the other pins for that matter. I see a GetStateMac, but don't think that produces the 0 to 1023 you've just mentioned. What am I missing?

-1


Top
 Profile  
 
 Post subject: Re: ARC-32 Performance Difference BASIC vs ASM
PostPosted: Tue Aug 02, 2011 10:21 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
No, GetStateMac is to read the digital state of a pin. It has nothing to do with hservostate.

To get a pins hservostate use this code.

and.w #0x1F,r0
add.w #_SERVOTBL,r0 ;calc table data address
mov.b @er0,r0l ;get table data
xor.b r0h,r0h ;isolate servo index

_hservostate_cont:
shll.w r0 ;Multiply index by 2
mov.w @(_HSERVOSTATE:16,er0),r0
shlr.w r0
shlr.w r0
shlr.w r0
shlr.w r0
shlr.w r0
shlr.w r0
xor.w e0,e0

r0 needs the pin number you want the value for. Obviously only pins with analog support willr eturn analog values.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO