Shop OBEX P1 Docs P2 Docs Learn Events
Need another set of eyes — Parallax Forums

Need another set of eyes

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2007-03-29 03:58 in Propeller 1
I'm beating my head against the desk on this.. Perhaps someone will see something I don't.

This chunk of code is excepting data from an 8bit bus. The trick is that the input bus lines are not running at consistent speeds. So I'm using a 9th line (pin8) to trigger when the lines should be looked at again. Perhaps there is a better way?

The basis idea is that when binary 11 is received, the lines are check again for a new input for b1,
when binary 12 is received , the lines are checked for b2 and so on.

   repeat
    cmdkey := ina[noparse][[/noparse] 31] << 7 + ina[noparse][[/noparse] 30] << 6 + ina[noparse][[/noparse] 15] << 5 + ina[noparse][[/noparse] 9] << 4 + ina[noparse][[/noparse] 4] << 3 + ina[noparse][[/noparse] 5] << 2 + ina[noparse][[/noparse] 6] << 1 + ina[noparse][[/noparse] 7]
    

    if cmdkey == 11
      repeat until ina[noparse][[/noparse]8] == 1
      data := ina[noparse][[/noparse]31] << 7 + ina[noparse][[/noparse] 30] << 6 + ina[noparse][[/noparse] 15] << 5 + ina[noparse][[/noparse] 9] << 4 + ina[noparse][[/noparse] 4] << 3 + ina[noparse][[/noparse] 5] << 2 + ina[noparse][[/noparse] 6] << 1 + ina[noparse][[/noparse] 7]
      b1 := data
      gr.SimpleNum(464,30,b1,3)
      cmdkey := 0  
      repeat until ina[noparse][[/noparse]8] == 0
        
    if cmdkey == 12
      repeat until ina[noparse][[/noparse]8] == 1
      data := ina[noparse][[/noparse]31] << 7 + ina[noparse][[/noparse] 30] << 6 + ina[noparse][[/noparse] 15] << 5 + ina[noparse][[/noparse] 9] << 4 + ina[noparse][[/noparse] 4] << 3 + ina[noparse][[/noparse] 5] << 2 + ina[noparse][[/noparse] 6] << 1 + ina[noparse][[/noparse] 7]
      b2 := data
      gr.SimpleNum(464,60,b2,3)
      cmdkey := 0
      repeat until ina[noparse][[/noparse]8] == 0


' ... additional lines


Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-03-28 07:44
    Now I see what's wrong! Confucius say "Man who beat head on desk too close to problem". so step back and pour yourself a drop of red instead. I'm not quite sure what you mean when you say "binary 12" as there is no such thing, however I can't see where you are reading in all the bits in one go before proceeding with rearranging bits. Is it possible that while you are busy reading in a bit at a time that the data changes?

    Also the b1 := data is redundant if you simply assign the data directly to b1/b2 in the first place.

    *Peter*
  • T ChapT Chap Posts: 4,209
    edited 2007-03-28 08:55
    Another solution to what you are trying to do is, download Mike's Minimal I2C Object. Get yourself an 8bit i/o expander, the one I like is the PCF8574(There is a DIP version available). It has 8 i/o's, it also has an interrrupt output that goes back to the Propeller. If any data changes on any of the 8 inputs on the 8574, the interrupt pin will go active(low), signalling the Propeller that a read is in order. The Prop then reads the pins via I2C on only 2 pins (can even be the two pins your EEPROM lives on). Once the data is read, your pin states are stored in whatever variable you want them to be stored in, or however you want to park the data. The code is very straightforward.

    I didn't test this, but the rough idea is close. Hopefully Mike will fix the Ack value for me.

    OBJ
      i2c   :   "minimali2cdriver"
    
    PUB waitForData
       Repeat
         Waitpeq   (%0, %1, 0)   'wait for interrupt to go low, data is present is low
             Readpins
       
    PUB  ReadPins
       i2c.i2cstart(28)     'start the transaction
       i2c.i2cwrite(28, %0100_000_0 + 1)    '   pin start(25), device type(0100), address(000), read mode(1)
       MyByte := i2c.i2cread(28, 1)    '(scl, ack)   read the byte, not sure here on the ack bit value
       i2c.i2cstop(28)
       
    
    



    Anyways, it's just an idea that might simplify your project. Mouser has the DIP in stock for $1.80.

    Post Edited (TChapman) : 3/28/2007 9:07:22 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-03-29 03:58
    Peter, Good Advice.. (Take a break) It worked...

    I dropped back to 8 bits using the 8th as my toggle, and things clicked right into place.

    I'm taking the propeller to a retro-computer show next month with a demonstration of
    a Commodore 64-->Propeller Vector VGA demo. It demonstrates the concept of using
    something like the Propeller as an add-on for retro-hobbiests like myself.
    Time to order a couple more protoboards for the road!

    I suspect we'll pick-up several more "propeller heads" as a result of the demo, as I intend
    to demonstrate FemtoBASIC, HSS, as well as the composite Graphics Demo.
    (Wonder if it's too late to adapt my interface for the Speech stuff? smilewinkgrin.gif )

    Here's a couple shots of my project..
    (The graphics are being commanded via 8bit interface from my 1980's computer.)
    BTW, thanks to several who have helped me learn a LOT in the last two weeks.
    --this is the most fun I've had in a long time, and the most sleep I've lost ever..

    Oldbitcollector
    408 x 308 - 33K
    408 x 308 - 14K
    408 x 308 - 19K
    408 x 308 - 14K
Sign In or Register to comment.