Shop OBEX P1 Docs P2 Docs Learn Events
Apin with the counter modules — Parallax Forums

Apin with the counter modules

Jack BuffingtonJack Buffington Posts: 115
edited 2010-03-13 12:41 in Propeller 1
I'm playing around with the counter module and there seems to be a discrepancy between the data sheet is telling me and what I am experiencing. Pretty much I can only set Apin to be zero or a multiple of four. If I try to set it to some other pin, that pin puts out no signal. What am I missing? I have tried doing this by specifying the apin in a long that I copy to ctra and also by using movs to get the pin into ctra but neither works. I have tried this on the Professional development board and also the Propeller demo board so it shouldn't be something with my processor.

Here is the code that I am using:

CON

  _CLKMODE = XTAL1 + PLL16X
  _XINFREQ = 5_000_000

var
long temp
pub  start
    cognew(@counterStart, 0)
    repeat
      temp := 0   

dat
org
counterStart
              mov       dira,IOpins
              mov       ctra,ctraData
              movs      ctra,#8
              mov       frqa,frqaData
jPoint        nop
              jmp       #jPoint

IOpins        long      $11111111               ' make all pins be outputs

              ' It seems like Apin can only be zero or a multiple of four. 
              ' Set up the peripheral into NCO/PWM single-ended mode
ctraData      long      %00010000000000000000000000000000    
frqaData      long      $40000000
fit     496

Comments

  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-02-22 22:47
    I have also tried this

                  mov       tempa,ctraData2
                  shl       tempa, #23
                  mov       tempb,#1
                  shl       tempb,#9
                  add       tempa,tempb
                  add       tempa,#0                ' this is the pin number
                  mov       ctra,tempa
    
    
    ... later in the program:
    ctraData2     long      %00100000   
    
    



    which should be the equivalent to the spin command:
    ctra    := %00100_000 << 23 + 1 << 9 + 0  
    
    



    With Spin I can set the pin to whatever I want but I would really rather not waste a whole cog on this. I would rather set up the counter at the beginning of another assembly language program and forget about it.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-22 22:47
    Your IOPins value ($11111111) sets only every fourth pin as an output.

    -Phil
  • BeanBean Posts: 8,129
    edited 2010-02-22 23:38
    Phil Pilgrim (PhiPi) said...
    Your IOPins value ($11111111) sets only every fourth pin as an output.

    -Phil
    I think he meant to use $FFFFFFFF that would make all pins outputs.

    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    ·
  • AribaAriba Posts: 2,690
    edited 2010-02-22 23:45
    You can write the counter mode like in spin, this makes it more readable.
    And you can use constants from a CON section in PASM for the pin number.
    Then your code will look like this:
    CON
      _CLKMODE = XTAL1 + PLL16X
      _XINFREQ = 5_000_000
    
      OutPin = 3
    
    VAR
      long temp
    
    PUB start
      cognew(@counterStart, 0)
      repeat
         temp := 0   
    
    DAT
                  org
    counterStart
                  mov       dira,PinMask
                  mov       ctra,ctraData
                  mov       frqa,frqaData
    jPoint        jmp       #jPoint
    
    PinMask       long      1 << OutPin
    ctraData      long      %00100_000 << 23 + 1 << 9 + OutPin
    frqaData      long      $40000000
    
    


    But your versions will also work if you set the right pins as output(s).

    Andy
  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-02-27 00:56
    Yep. It usually is the stupid stuff that gets me. I'm used to working with 8-bit micros and usually set my I/O directions manually in binary so that looked right to me since all eight of them were 1's. Thanks for the help. Next thing is to see if the output actually works as a clock source for something that I am trying to drive. My oscilloscope shows a pretty funky waveform coming out of the pins but it will probably be OK. I stuck a high speed buffer onto my prototype board just in case.

    -Jack
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2010-02-27 01:19
    What kind of funky output? Can you show a screen shot of the signal? The clock/counter output should work well as a clk for a high speed output as others have done it and I myself am working through a design as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-03-13 00:53
    I saw a lot of ringing and other quirks in the signal coming out but eventually tamed it by just adding a series resistor.

    The ringing was shooting a good volt above and below my power rails.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-13 02:35
    The ringing you observed is likely due more to your measurement technique than to the Propeller's actual output behavior. The Propeller outputs have extremely fast rise times. Unless you use scope probes without their clips and with very short ground leads (i.e. a short wire attached to the ground ring and soldered directly to the board), you will see the apparent ringing that you report.

    -Phil
  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-03-13 04:50
    I'm pretty sure that my scope is fine. The signal coming out of the calibration post looks fine and has no over/under shoot. It is a nice crisp square wave. At first I was testing on the propeller demo board so I can see that things wouldn't be ideal but now I am working on a printed circuit board where I'm using the lqfp part and the trace to the other part is about 1 1/4 inches long with no sharp angles or vias.
    Here is how it looked before the series resistor:
    4428781632_6e2dc9912d_m.jpg

    And here it is afterwards;
    4428015561_f1754bb974_m.jpg

    It still isn't perfect but looks better to me. Probably both are really fine for my application but I am driving the clock to an A/D so I was worried about the over and under shoot adding noise to my data.

    I should say that I am overclocking this propeller to 100MHz rather than 80MHz. I'm not sure if that really matters since I am only having the counter run at 25MHz so the output driver isn't being pushed faster than it is spec'd for. Also, looking at my own picture, I see that at least as I was measuring it there, it was only ringing about .75V above and about .6V below the rails but still....

    -Jack
  • hover1hover1 Posts: 1,929
    edited 2010-03-13 12:41
    There was a recent thread on the ringing problem. A series resistor was the solution.

    ·http://forums.parallax.com/showthread.php?p=885691

    Jim
Sign In or Register to comment.