Shop OBEX P1 Docs P2 Docs Learn Events
Propeller FLIP 32123 40pin dip package, where is SPI — Parallax Forums

Propeller FLIP 32123 40pin dip package, where is SPI

Sunshine436Sunshine436 Posts: 16
edited 2024-11-10 16:23 in Propeller 1

Assembled the prototype board have the FLIP module there, now looking for info about programming the SPI?

Im not finding a datasheet or info except for I2c I had called in and explained the SPI requirement and was recommended to get this.

Am programming a Micron flash NOR memory 8pin package. just need an SPI master to r/w

problem is, the memory DATA IN and DATA OUT are multiplexed into a chip, so you have DATA and dataDIR. to program it, you pull direction low connecting the MOSI to the data in. then after that command write finishes that dataDIR has to be driven high to connect the MISO to data out

so Im trying to find an SPI routine where I can just change a pin, some general purpose DataIO pin high/low as data direction. its not fast, maybe a 1Mhz r/w

does anyone use this board for SPI? thanks

Comments

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-10 16:22

    There is no SPI hardware in the P1 so you can bit-bang as you need. The attached ADC library shows how to change the direction of the data pin on-the-fly. It's very simple, though in Spin, not very fast. If you're going to move a lot of data and need to do it quickly you'll want to convert to PASM or use a compiler like FlexProp.

    Tip: If you attach the datasheet (or a link to it) for the component you want to connect with, there are several people here who can offer more specific assistance.

  • Sunshine436Sunshine436 Posts: 16
    edited 2024-11-10 17:02

    Thanks for the super fast reply. https://www.alldatasheet.com/datasheet-pdf/view/156809/STMICROELECTRONICS/M25PE80.html

    seems to be close to this part. Ive sent single cmd 0x9F and it replies

    Not sure why they told me to get this P1 when there is no SPI controller. described the problem, SPI that i can manage the low level steps, standard SPI wont work, have to use this data direction. I had described exactly the problem and they put this order together for me.

    The biT bang example is i2c ? (tried twice to edit this)

    This memory's data in/out are wired in to a 2:1 mux. if the bit is high its one line, low its the other. I set the memory protect line HIGH so its inactive, and cannot access those setup registers to see what its set to.

    Thanks for any info/guidance

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-10 18:58

    I find your initial question confusing after looking at the datasheet. It looks like standard SPI to me with the pins renamed.

      S\    CS\     Chip Select
      D     MOSI    Data in  (from master)
      Q     MISO    Data out (to master)
      C     SCL     Serial Clock
    

    Figure 4 in that document shows Q (MISO) connected to the SDI (data in) of the master device.

    I've attached a simple library that I wrote for a friend that runs on the P1. I think he used the same W24Q128 flash that is on the P2. It should be helpful -- not that it will work with your chip, but that it will show you how I successfully wrote bit-bang SPI code for a flash chip. This code is used in a commercial product, so we know it works.

    Not sure why they told me to get this P1 when there is no SPI controller.

    Who's "they," and what's the problem? Even with a SPI controller you'd need to know how to deal with the specific device which would probably involve a library. In this case the library will bit-bang SPI instead of using a dedicated controller (that will usually limit which pins you have to use; not the case with the P1). The Propeller family has a different architecture than other chips; it's much more flexible if, at times, requires a little extra work. Most of use find it worthwhile. I've developed and coded many commercial products with it.

    The biT bang example is i2c?

    No. The ADC0838 is a standard SPI device, but that code connects the MOSI and MISO pins together (via a resistor) to save a pin since the data from/to the Propeller to the chip is half-duplex.

  • JonnyMacJonnyMac Posts: 9,110

    seems to be close to this part. Ive sent single cmd 0x9F and it replies

    Whoops, I somehow missed this. Specifics matter. What chip/device are you using? Don't make people guess or give bad information.

  • thanks for the code example! will try to test with that

    I have one of these M25P80 memory chips in a breadboard, can do r/w to it with national instruments hardware; but in the circuit its being tested? no, the data lines are muxed, the direction bit has to be at the exact moment the write cycle ends, while CS is still active. I dont have a drawing of that.

    Looking at the datasheet I set the clock phase and any settings, first 4 bytes are the command, then 3 bytes of address MSB first top nibble ignored. I want to try at 08 00 00 and write 55/AA. sending something like
    single command write enable

    record script
    CS low
    0x06 //WREN
    (ignore result)
    CS high

    CS low
    write buffer:
    0x02
    0x08
    0x00
    0x00
    0xAA

    write/read script command (NI)
    direction bit high
    CS high
    end script
    run script //runs and collects the read data automatically
    extract read size
    for(size )
    array x = extract read data (size)
    display x.ToString()

    always returns 0

    looking forward to another approach with this P1 thanks again

  • @JonnyMac said:

    seems to be close to this part. Ive sent single cmd 0x9F and it replies

    Whoops, I somehow missed this. Specifics matter. What chip/device are you using? Don't make people guess or give bad information.

    Micron M25PE80 is the part. The suffix i thought were package/temp unrelated to operation its an obsolete PN; should be compatible with the current M25P80. was not able to get any assistance from Micron. I will have to find the remainder of the part, but that is the literal part.

    sending 0x9F confirms it. the datasheet matches this memory.

  • JonnyMacJonnyMac Posts: 9,110

    This chip?
    -- https://docs.rs-online.com/c46f/0900766b8121bd29.pdf

    It works with Mode 0 SPI so you should be able to adapt code from my jm_ez_flash.spin library to work with it.

      DQ1       MISO
      DQ0       MOSI
      C         SCL
      S#        CS\     Connect to pull-up
      RESET#            Connect to pull-up
      WP#               Connect to pull-up 
    
  • Yes that is the correct datasheet.

    which IDE do you recommend? Im used to visual studio but if this SimpleIDE works great Id like to learn

    Id add your .spin library to a project and then call from the main() method?

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-11 02:27

    Depends on language.
    -- For Spin use Spin Tools IDE from www.maccasoft.com (I only uses Spin/PASM so this is the tool I use)
    -- For Spin, BASIC, and C (and you can mix them), use FlexProp. The IDE is not fancy, but it works
    -- Another option for C is Catalina (though I've not been able to get recent versions to work on my PC)

    The Spin1 code I provided will not work with Catalina; it will work in Spin (of course), and FlexProp has syntax that allows for libraries in other languages.

    Id add your .spin library to a project and then call from the main() method?

    Think of a Spin library (often called an object) like a class from other languages. You have to reference it, insatiate it (in Spin we tend to use a method called start() to instantiate the object), and then you can call methods. Some methods will return values, some will not. Spin1 can only return a single value so you may see cases like this.

    pub jedec_info(p_mfg, p_type, p_size)
    
      outa[cs] := 0
      shiftout($9F, 8)
      byte[p_mfg]  := shiftin(8)
      byte[p_type] := shiftin(8)
      byte[p_size] := shiftin(8)
      outa[cs] := 1
    

    Spin doesn't have a special pointer type, so I indicate a variable is a pointer with p_ in front of an appropriate name. To call the method above you might do this from your app.

      flash.jedec_info(@manufacturer, @devtype, @devsize)
    

    The @ operator provides the runtime address of an object.

    If you've done other programming it will only take a couple days to get familiar with Spin. Spin1 is small and concise. The attached template will show you how Spin1 programs are structured.

  • Thanks glad i asked, already on the 3rd ide, downloaded maccasoft.

    chasing a lost com port. simpleide connected and loaded some hello world code to this flip. Trying to use another IDE it couldnt connect to COM3. instead of restart thought Id just uninstall the port, then reinstall.

    no, now its not working at all. this is a PC called Beelink, a 3 inch by 4inch box and there is the PC. Nonstandard motherboard. wasted an hour trying to get COM3 back. it brought back COM4 trying to install legacy hw, but says its not setup right, wants to manually set the irq, tried all the options, 3 or 4, reboot, same.

    we had the one hurricane that passed our way and it was humid and rained and my pc just shorted out i guess. cleaned that for hours, bios says the power supply is way off, too much voltage on the cpu, so i just ordered one of these and set it up.

    so close to having an IDE work. Ive been on visual studio past 15 years or so and did web and winforms so a class reference, cool that makes sense. did asm and machine code long ago in another universe. so that passing pointers looks kind of ok hope it makes sense soon.

    idk how to get the com port back on this; if it was a std motherboard it would be enabled i think

  • new spin file or new C file?

    how do i reference your .spin file?

  • JonnyMacJonnyMac Posts: 9,110

    I sent you a template archive that shows how Spin files are organized. At some point, you're going to have to knuckle down and learn Spin. Again, if you have done some programming it will be easy because it's a very small language (Spin1).

    I don't use C with the Propeller; anything I give you will be Spin intended to run through the standard Spin interpreter.

  • Ill recheck that. I want to learn it, am just in a hurry to get this to work and missed it, had to have it Sunday to be ready for Monday to say yes its got coms with the spi. the usb cable is bad, just connect the cable and windows says usb device not recognized, usually means wires are shorted. Ordered a cable and find out now they substituted it for a usb C and wall charger kit.

    Now the question is, are the main flip connector pins, the USB i/o pins extended out to the port pins, i could salvage some usb cable and solder the wires onto the board since getting usb micro B is so impossible.

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-11 23:26

    The FLiP has an FTDI USB-to-serial adapter chip soldered to the bottom side of the board. If you connect an external circuit to P31 and P30 (programming pins), you're bound to break something.

    ...getting usb micro B is so impossible.

    Are you on the moon?

  • Sunshine436Sunshine436 Posts: 16
    edited 2024-11-12 14:57

    moon? well Im not back home in SoCal. Will order a cable yet again, roll the dice and see what happens. where I am has 1/1000th the tech as there

    order usb micro B sync cable. we substituted with a usb C charger cable, that must be what you meant to order?

    saw those pins and super tiny SMD resistors? ur so right, yeah no thanks.

  • Hi!

    Not entirely sure I understand all your comments, but about the USB cable....

    The FLiP module requires a microUSB type cable for power and programming

    The FLiP module ABSOLUTELY requires a microUSB cable with data capability. A simple "charger only" cable will not work.

    Why ? The FLiP needs to communicate with your computer for programming, so it ABSOLUTELY requires a quality data cable to do that.

  • yes a data or sync cable with all 4 wires. the 2 wire charger cable, Ive got 2 of them the 3rd data cable is shorted/damaged

    plug in that cable? with nothing on it? windows error: usb device not recognized. it had worked once

    I ordered the right cable and Ive ordered 2 more hoping one might be the right one. FLIP should do as other mfrs put those usb lines into points that can be grabbed with wire

  • @Sunshine436 said:
    FLIP should do as other mfrs put those usb lines into points that can be grabbed with wire

    To be fair, the FLiP could be programmed using an external connection (WiFi module or external serial uart, like a PropPlug); the pins are broken out. You shouldn't start by thinking there are any limitations like that. However... it's an unsupported and advanced configuration. Certainly one of those situations where if you don't recognise the connections, you shouldn't be using them.

    As you learn more about how the Propeller programming interface works, then you could figure out how to use the external connections safely, over time.
    Things like that are easy to get wrong if you don't know what the inner workings are doing. I think Jon said it well... you'll be more likely than not, to rush in and damage something!

    Definitely stick with the built-in USB connector, as the module is designed! It just works and is absolutely reliable. Small and certain steps forward!

  • thats fine, but time is an issue here; cable might arrive tomorrow; but Id like to know this connection mechanism you mention? the warning is to solder wires onto that usb connector or the 2 R's right there, if they were 1206 smd's no problem, what are those 105's? iron touches it, its all over. hot air, microscope, flux, then superglue i dont have the setup.

    the schem says the usb lines go into that serial uart thing, but please lmk what you refer to

    annoying going into Wed now not able to code up spi

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-13 17:46

    You'll be even more annoyed if you damage or destroy your FLiP module. Pins 31 and 30 of the Propeller 1 connect to an active circuit (FTDI USB interface); I don't think it's a good idea to attempt to hack into this, especially with raw USB that the P1 cannot deal with (hence the FTDI chip).

  • just got the cable. connect and the propeller ide cant open the device and says com3 cant open, will look for the ide you suggested and try

    no am not going to hack, it would require super small rework

  • USB to Micro USB Cable 6ft, MicroUSB A 2.0 480Mbps Data Transfer & 12W Charging Cord Braided for Android Old Kindle, Paperwhite, Tablets, Phone, MP3 and More

    run and it cannot find any P1 device

    got as data transfer cable, but any idea how to see it from the IDE? tools/ports> COM1 only port there

  • JonnyMacJonnyMac Posts: 9,110

    Make sure you have the latest FTDI drivers installed for you OS.

  • i went into device manager win + R devmgmt.msc in com ports com3 was disabled. Enabled and works now

    thanks

  • setting up the flash mem to write/read. this one M25PE80 takes 3 addr bytes, A20:0
    Read is 0x03
    when you say addr.byte[3] = 3 is the 4th byte the command 0x3? are 0, 1, 2 the address?

    pub rd_block(addr, n, p_dest) | b

    '' Read block of bytes from flash
    '' -- n is number of bytes
    '' -- p_dest is hub address of output block

    addr.byte[3] := $03

    outa[cs] := 0
    shiftout(addr, 32)
    repeat n
    byte[p_dest++] := shiftin(8)
    outa[cs] := 1

  • JonnyMacJonnyMac Posts: 9,110

    Yes. .byte[3] is the MSB byte of a long. You pass the address (which must fit into 24 bits). The MSB is set to the read command ($03) and the 32 bit value is shifted into the flash.

  • ok interesting.... Im doing SPI on the national instruments 8452; seems like on that its byte[0] = cmd then 1,2,3 are addr 20:0 will have to try something different

    I have the board wired up for the mem interface but now trying to learn the propeller spin code style

  • JonnyMacJonnyMac Posts: 9,110
    edited 2024-11-25 02:26

    Don't mistake the byte position with the order in which they are shifted to the device. The values are being shifted out MSBFRST, so the order going out is byte 3 (cmd), byte 2 (high byte of address), byte 1 (middle byte of address), and then byte 0 (low byte of address).

         MSB            LSB
    <-- [ 3 ][ 2 ][ 1 ][ 0 ]
         cmd  -- address --
    
Sign In or Register to comment.