Shop OBEX P1 Docs P2 Docs Learn Events
Fast Pin-Toggling — Parallax Forums

Fast Pin-Toggling

MXMikeMXMike Posts: 3
edited 2009-05-21 15:01 in General Discussion
Hi everyone,

i have some questions.

I need to toggel some pins with a speed about 25 Mhz.

Is this posible with a parallax sx?
And if yes, with which one... are the eval-boards for it?

Regards

MXMike

Comments

  • BeanBean Posts: 8,129
    edited 2009-05-20 11:38
    Mike,
    The SX48 can do this with one of it's internal timers by running the SX at double the required frequency.
    So by running the SX48 with the 50MHz resonator you should be able to get a 25MHz output.

    If you are just getting started with the SX, I would recommend the SX Tech Tool Kit ($90)
    http://www.parallax.com/Store/Microcontrollers/SXProgrammingKits/tabid/140/ProductID/364/List/1/Default.aspx?SortField=ProductName,ProductName

    Then you'll need the SX48 protoboard (only $15) http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/SX48/List/0/SortField/4/ProductID/362/Default.aspx

    If you need a more flexible frequency generator, then you might look into the Propeller chip. It can create a wider range of frequencies because it has built-in PLL's to increase the counter frequency.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...



    Post Edited (Bean (Hitt Consulting)) : 5/20/2009 1:00:37 PM GMT
  • MXMikeMXMike Posts: 3
    edited 2009-05-20 12:40
    Hi Bean,

    thank you for you answer.

    You say the SX can do this with it's internal timers.

    I need this frequency in the main loop. I need to fill a few SPI devices.

    Is the Pin-Toggeling faster with the propeller?

    Remember please, i don't ne a special frequency. I need to fill a few SPI devices and an FPGA.

    Regards

    Mike
  • BeanBean Posts: 8,129
    edited 2009-05-20 13:01
    Mike,
    The timer will toggle the pin regardless of what the main code is doing. You can turn the timer on and off to start or stop the counter output, but you will not be able to send data at 25MHz.

    Are you just sending zeros ? Or do you need to send actually data to the SPI device ? More info please....

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-05-20 17:58
    > but you will not be able to send data at 25MHz

    Hi Bean,

    related questions, if you please. If you double the freq as you mention (50MHz yields 25MHz pin toggle), would there be enough code-speed headroom left to bit-bang serialized data ?

    [noparse][[/noparse]note the thread where I asked about 100MHz clocking] This is interesting, if the calculation is that simple --- or wait, er no, it's just the way the timer works, e.g. if the chip is clocked at 100MHz, then the fastest timer would be 50MHz (Y/N)? At 100 could a I2C-like setup (1 pin SCL, 1 pin SDA) with the ISR overhead drive the two pins at 25MHz using the internal timer to trigger the interupt ? I know it can be setup that way, but the speed issue is really what I'm asking. (And perhaps MXMike will have to deal with similar issues. --- Hey, Mike, I'm just jumping in a sec .. don't want to highjack your thread burger.gif )

    thanks,

    Howard in Florida

    PS Bean *thank you* for all your support and work!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buzz Whirr Click Repeat
  • BeanBean Posts: 8,129
    edited 2009-05-20 18:26
    This program:

    DEVICE SX28, OSCXT2, BOR42 
    FREQ 50_000_000 
    
     
    value VAR BYTE 
    
    ShiftReg PIN RC OUTPUT ' Data is output on pin RC.0 
    ClkPin PIN RB.0 OUTPUT 
    
     
    PROGRAM Start 
    
     
    Start: 
      FOR value = 0 TO 255 
        ASM 
          CLRB ClkPin 
          MOV ShiftReg,value ' Output bit 0 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 1 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 2 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 3 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 4 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 5 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 6 of value 
          SETB ClkPin 
          CLRB ClkPin 
          RR ShiftReg ' Output bit 7 of value 
          SETB ClkPin 
        ENDASM 
      NEXT 
    END
    

    Sends 2048 bits in 153.58uSec or 13.33 MHz.

    P.S. This probably wouldn't work in the real world because of the back-to-back I/O on the ClkPin.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • MXMikeMXMike Posts: 3
    edited 2009-05-21 06:38
    Hi Bean,

    i need to send Data.

    Your example is that what i need but its to slow. Do you know if this will work faster with a propeller ?

    Regards

    MXMike
  • LeonLeon Posts: 7,620
    edited 2009-05-21 09:35
    It's slower than an SX - 100 ns (10 MHz) just to toggle an output pin, IIRC. If you need 25 MHz you will have to use something a lot faster.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle

    Post Edited (Leon) : 5/21/2009 9:41:25 AM GMT
  • BeanBean Posts: 8,129
    edited 2009-05-21 11:12
    The propeller might be able to do it by using the Video Generator to send the data.
    I would try using VGA 2-color mode, one bit would toggle each "pixel" for the clock, the other bit would be the data, and would update every other "pixel". The other 6 bits wouldn't be used.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • pjvpjv Posts: 1,903
    edited 2009-05-21 14:34
    Hi MXMike;

    By cranking the SX up in frequency to 80 Mhz (or more) and with interleaving code, you might be able to do what you need. Unfortunately you have inadequately descibed the "other things" the SX needs to do, either simultaneously, or consecutively with generating the 25 MHz pulse train, so it is impossible to say for sure.

    A complete description will make that assessment possible.

    For what its worth, I have many systems where I burst data out of an SX at 10 Megabits/second with a 50Mhz resonator. I know that isn't 25 MHz, but simultaneously it also does other things.

    Cheers,

    Peter (pjv)
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-05-21 15:01
    ...      MOV ShiftReg,value ' Output bit 0 of value 
             SETB ClkPin 
             CLRB ClkPin 
             RR ShiftReg ' Output bit 1 of value 
             SETB ClkPin 
             CLRB ClkPin 
    ...
    

    P.S. This probably wouldn't work in the real world because of the back-to-back I/O on the ClkPin
    

    A while back,·having problems with SETB/CLRB rapid fired, a look in the 'manual' said something to the effect that toggling a pin this way
    could cause uncertain results.· Sorry, I can't find the quote at the moment. Think it was in the area about an external device pulling a pin low when the SX was trying to push it high.· Am also wondering if, at these speeds,·there could be a capacitive/impedance factor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    No matter how much you push the envelope, it'll still be stationery.
Sign In or Register to comment.