Shop OBEX P1 Docs P2 Docs Learn Events
Sending Serial Signals with the Propeller — Parallax Forums

Sending Serial Signals with the Propeller

rcm14rcm14 Posts: 11
edited 2012-02-21 01:38 in Propeller 1
Hello all.

I am an EE student using the Propeller for a design project. I need to send a serial signal through a laser diode module to communicate with a photosensor both of which are connected to Propeller chips.

My concern is the speed at which I can output the bit stream I need to send. I outputted a simple square wave through one of the pins and connected that pin to an oscilloscope to view the frequency of the output. I used the following code to implement the simple square wave:
PUB FREQ_TEST


dira[0]~~
outa[0]~
repeat
!outa[0]


(I had the clock frequency set to 80MHz)

Using this code, I was only able to achieve a square wave with a frequency of 45kHz. I would like the output speed to be faster than this. Will using assembly make the frequency faster?

Any help and guidance would be greatly appreciated.

Comments

  • ThricThric Posts: 109
    edited 2012-01-23 19:14
    I would recommend using the cog's counter to modulate the pin instead of the cog. Although I'm not very knowledgeable on this, as I've never really had to use the counters myself quite yet, a quick look into the propeller manual states that it can generate frequencies between 64MHz and 128MHz.
  • AribaAriba Posts: 2,690
    edited 2012-01-23 19:17
    Yes Assembly would be much faster.
    With this code:
    CON
      _clkmode  = xtal1 + pll16x
      _xinfreq  = 5_000_000
    
    PUB main
      cognew(@asm,0)
    
    DAT
          org 0
    asm   mov dira,#1
    loop  xor outa,dira
          jmp #loop
    
    you should get a squarewave of 10 MHz at P0.

    With the help of a counter the Propeller can generate squarewaves up to ~160MHz !
    With the help of the videoshifter you can send serial bitpatterns with 50MHz or more.
    Receiving is more tricky but should be possible up to 10MHz.

    Andy
  • T ChapT Chap Posts: 4,223
    edited 2012-01-23 19:33
    Welcome to the forum rcm. You can look at the app note on counters here:

    http://www.parallaxsemiconductor.com/an001

    You can use the counter to experiment with turning on and off a pin at very low frequencies all the way to the props maximum frequency.
    If you wanted to test some of the existing serial transmission rates, use for example the Full Duplex Serial object, set the tx pin and baud, and experiment with various frequencies to see if something will serve your purposes to achieve the highest rates possible with the laser diode and photo detector.
    CON
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    
    OBJ
         ser     : "fullduplexserial"
    
    PUB Start
        ser.start(24, 23, 0, 19200)    'Rx Tx mode baud
        runtest
    
    PUB RunTest
       Repeat
          ser.str(string("UUUUUUUUUUUUUUUUUUUUUUUUUUUU"))
          ser.str(string("UUUUUUUUUUUUUUUUUUUUUUUUUUUU"))
          ser.str(string("UUUUUUUUUUUUUUUUUUUUUUUUUUUU"))
    
    

    You can look at your scope on the photo detector circuit and find out where your signal starts to degrade at what baud.
  • rcm14rcm14 Posts: 11
    edited 2012-02-21 01:38
    Thank you all for the responses. After much trial and error, I have found that the Full Duplex Serial object does exactly what I need it to do.
Sign In or Register to comment.