Shop OBEX P1 Docs P2 Docs Learn Events
Debugging: Propchip, VMusic2, Atmel 64Megabit Flash, 16bit Shiftregister — Parallax Forums

Debugging: Propchip, VMusic2, Atmel 64Megabit Flash, 16bit Shiftregister

VadooVadoo Posts: 92
edited 2009-09-27 15:06 in Propeller 1
Debugging: Propchip, VMusic2, Atmel 64Megabit Flash, 16bit Shiftregister.

I have gone as far as I can. Proggress has slowed to a crawl....
I have 5 objects wirtten out to where they make sence to me, but now I need to make them make sense to the Prop....
99% of what I have, I believe to be correcet(that means its ready for someone more experianced to make it work!).
The other one percent I just havent figured out how to write correctly.
If anyone is interested in helping me debug 5 objects let me know. Any amount of help is greatly appreciated.

I have only uploaded two of the objects, SYNC.spin and SPI.spin. I also use FullDuplexSerialPlus.spin ( from PE-Lab-Objects-v1.1) which i have not altered, and a Main, and shiftregister driver object.

Main only calls SYNC, and waits untill it is finnished.

Thanks!
Ryan.

Comments

  • KyeKye Posts: 2,200
    edited 2009-09-14 02:55
    You'll need to post everything if you want help. If there is no code there's not much anyone can do.

    Also, please note to the users here what parts of the code have been altered and what you suspect the problem is. Please do not try to abuse volunteer help.

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • VadooVadoo Posts: 92
    edited 2009-09-14 04:28
    "You'll need to post everything if you want help. If there is no code there's not much anyone can do."

    I posted what I cant get to work at the moment. Sorry for the lack of information.
    I honestly thought the two objects I posted would be easy to understand as I am certainly not an expert and I made lots of comments on them.
    I posted a SYNC object which takes the number of files to be read into flash, from a main file(all located on the thumb drive in the VMusic2). Then reads those files into flash. SYNC uses FullDuplexSerialPlus.spin to read from the VMusic2 and SPI.spin to write to the flash chip.
    Did you look at the two files?

    "Also, please note to the users here what parts of the code have been altered and what you suspect the problem is."

    If I had any idea of the problem I wouldnt be asking for help. As I mentioned, I have gone as far as I can, I need someone more familiar to look at the code I posted and tell me if its even writen properly. I do think part of the problem is that is not written out correctly in some places. I know in some places I have nothing setup to wait for the first task to complete and runs the next one interupting the first, and I'm not sure how best to·change·that..
    If one of the big brains on here looks at my code I·imagine they could tear it apart in seconds and set me back on track again.

    "Please do not try to abuse volunteer help."

    Thanks for the brilliantly insightfull remark, Ill keep that in mind...
    If you have anymore just list them under 'The Sandbox' and Ill take a look at them later, promise.
  • mparkmpark Posts: 1,305
    edited 2009-09-14 05:04
    Vadoo said...

    "Please do not try to abuse volunteer help."


    Thanks for the brilliantly insightfull remark, Ill keep that in mind...

    If you have anymore just list them under 'The Sandbox' and Ill take a look at them later, promise.

    I'm not sure such a sarcastic response to well-intentioned advice is a good strategy. I bet Kye could have helped you, but I rather doubt he will now. You might want to reconsider how you interact with people you're asking for help.
  • BADHABITBADHABIT Posts: 138
    edited 2009-09-14 22:16
    lol.

    That statement from Kye only made me think of ways to abuse volunteers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BH skull.gif
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-09-14 22:29
    Vadoo - keep in mind that many here do not use English as their primary language --- Kye might not have ment his good advice to come across as sternly as it sounded.

    In any case, welcome to the forum - and Kye is so nice that he might forgive you stepping on his virtual toes. [noparse]:)[/noparse])

    Cheers
    - Howard

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • KyeKye Posts: 2,200
    edited 2009-09-15 00:20
    Well, I looked at your code and I wasn't sure what's it doing because I don't know what the top object is the how everything is constructed. I though I might get an unhappy responce back from you but since your just posting I needed to tell you the rules here so that you can post as much information as possible for me to help.

    So, here's what I can see with limited info.

    ...

    I don't know what the spi object is interfacing to. Not sure what to say about it.

    ...

    So, the:

    SPI.start(clkfreq/100000,0)············ 'FIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx

    Line I belive takes an argument in 10us increments after looking at the source code. That said the clkfreq/10000000 provides an improper number to the driver. You should be providing a number like 1.

    ...

    buffindex += 16······· 'skip to three digit number of sequences
    bytemove(@temp1, @buffer[noparse][[/noparse]buffindex], 3)··········· 'store number of sequences to temp1

    Since temp1 is a long this line looks a bit weird. Is the received number in ASCII form or in binary? If its in ASCII you need to convert it to binary first using the inverse of a dec statement. I belive numbers.spin in the proplibrary·will do this. If its in binary it should have 4 bytes, not three. Unless·whoever made the thing you are communicating·to made it different.

    I say this because you use temp1 later as a count down variable.

    That said,

    repeat until temp1 <> 0

    and

    temp1 := (temp1 - 1)

    Won't work because·if temp1 is non zero first off the loop will exit.·It should be "repeat until temp1 == 0" or "repeat while(temp1)"

    ...

    FileSize := @buffer[noparse][[/noparse]0]·· 'save FileNum size to FileSize··· FIX????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

    Doesn't look right. You may want to use bytemove like above with 4 bytes. Or however long the number is. Again if its in ASCII form it needs to be converted to binary. (This is differnt from binary to ASCII).

    ...

    That's what I can debug for now. As I said before. Try to give me a rough ball park of where the problem statment or function is. Without that I don't know the difference between a hack and a valid piece of code. I just spent 30 minutes looking at your code. For me I really would rather not do that so it makes it easier for me to help you if you give me a rough idea of what's wrong. I'm not saying I won't help, but I have other things to do also... That is what I meant by abusing volunteer help.

    =)

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 9/15/2009 12:26:20 AM GMT
  • VadooVadoo Posts: 92
    edited 2009-09-15 01:34








    "Well, I looked at your code and I wasn't sure what's it doing because I don't know what the top object is the how everything is constructed. I though I might get an unhappy responce back from you but since your just posting I needed to tell you the rules here so that you can post as much information as possible for me to help."

    Hah ok well since we are all past that thanks for continuing to help out[noparse]:)[/noparse]

    I know I gave very little info, sorry I was in a hurry[noparse]:([/noparse]

    "I don't know what the spi object is interfacing to. Not sure what to say about it."
    The SPI object isnt noted well. Its from SPI_SPIN.spin but mildly altered.
    (This only applies to what SYNC uses it for) Its ment to take the buffer that is filled from the VMusic2 using the FullDuplexSerialPlus, and store it to the Atmel 64Megabit data flash chip.
    "SPI.start(clkfreq/100000,0)············ 'FIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx"
    The Flash chip can run at 85MHZ, how do I set up to clock at that speed?

    "buffindex += 16······· 'skip to three digit number of sequences
    bytemove(@temp1, @buffer[noparse][[/noparse]buffindex], 3)··········· 'store number of sequences to temp1


    Since temp1 is a long this line looks a bit weird. Is the received number in ASCII form or in binary? If its in ASCII you need to convert it to binary first using the inverse of a dec statement. I belive numbers.spin in the proplibrary·will do this. If its in binary it should have 4 bytes, not three. Unless·whoever made the thing you are communicating·to made it different."

    All information from from the VMusic2 I believe is sent in binary with exception of the filesize command(see bottom of this reply)

    I will·upload examples of·the files being read. I cant answer a lot about them, I didnt creat the program that compiles them, I just know what information I need off of them.

    "repeat until temp1 <> 0

    and

    temp1 := (temp1 - 1)

    Won't work because·if temp1 is non zero first off the loop will exit.·It should be "repeat until temp1 == 0" or "repeat while(temp1)"·"

    For some reason I thought <> ment =····

    Thanks that should clear up some issue.

    "FileSize := @buffer[noparse][[/noparse]0]·· 'save FileNum size to FileSize··· FIX????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

    Doesn't look right. You may want to use bytemove like above with 4 bytes. Or however long the number is. Again if its in ASCII form it needs to be converted to binary. (This is differnt from binary to ASCII)."

    There is one of the big ones. I dont know always what the file size will be. And Im slightly confused if the VMusic2 is returning binary or ASCII. I know it can do both but no clue what the default is, I cant find that answer........

    How do I take a value(filesize) and save just that value if I dont know how big the value will be(how much of my buffer is storing it)??????
  • KyeKye Posts: 2,200
    edited 2009-09-15 02:05
    Well, I wrote a bunch of stuff and the forum software didn't take my text so I'll keep this short as to not type this again.

    I believe you have a real problem with ASCII to binary conversion.

    Use the attached string library to fix this. Use the string builder functions (putCharacter) and (getCharacters) to build strings from indivual characters and then call the decimalToNumber function on them to turn them into binary numbers from ACSII numbers.

    I reconmend that you process one part of the string at a time instead of laoding it into a giant buffer an doing so. Get the number of characters needed at a time for one token and either then flush them or process them using my string library.

    Text-Shorted-Good Luck!



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • VadooVadoo Posts: 92
    edited 2009-09-16 01:37
    I confirmed today with Vinculum and your right I will need an ASCII to binary converter. I will look at the one you sent me this week end when I have some more free time.




    "I reconmend that you process one part of the string at a time instead of laoding it into a giant buffer an doing so. Get the number of characters needed at a time for one token and either then flush them or process them using my string library."

    Can you explain that a little more?


    Also I had some more questions in my last reply if anyone can touch on a couple of them.
    I had a couple more things but need to keep it short for now. I will wait for your reply and get the first questions out of the way!
    Thanks.
  • KyeKye Posts: 2,200
    edited 2009-09-16 03:42
    What I mean by processing one part of the string at a time is that you should load in the 3 character squence for the decimal number into my string processing library and then convert that number. Store it and then load in the next number of bytes to convert. Read the documentation on all the functions in my library and you'll see its pretty easy.

    (again use the putCharacter getCharacters function to build string and then convert them with the decimalToNumber function)

    ...

    As for SPI running at 85Mhz the prop cannot do that because... well it runs at 80 Mhz and it needs to excute instructions and its in spin so... you'll see preformance in the Khz. Use the assembly spi driver for faster speeds. However the preformance will still be no where near 85Mhz more like 1Mhz.

    ...

    Lastly, seems that the file uses linfeeds or carriage returns (decimal 10 or 13) to sperate the file. So the idea behind sequencial string processing is to look for those characters to tell you when to process what you have and then move onto the next token.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • VadooVadoo Posts: 92
    edited 2009-09-20 00:08
    Kye said...
    What I mean by processing one part of the string at a time is that you should load in the 3 character squence for the decimal number into my string processing library and then convert that number. Store it and then load in the next number of bytes to convert. Read the documentation on all the functions in my library and you'll see its pretty easy.

    (again use the putCharacter getCharacters function to build string and then convert them with the decimalToNumber function)

    ...

    As for SPI running at 85Mhz the prop cannot do that because... well it runs at 80 Mhz and it needs to excute instructions and its in spin so... you'll see preformance in the Khz. Use the assembly spi driver for faster speeds. However the preformance will still be no where near 85Mhz more like 1Mhz.

    ...

    Lastly, seems that the file uses linfeeds or carriage returns (decimal 10 or 13) to sperate the file. So the idea behind sequencial string processing is to look for those characters to tell you when to process what you have and then move onto the next token.

    I found·the ExtendedFullDuplexSerial.spin.·Would this work·better for recieveing larger·chunks of data?·I see I would need to change it from stopping after a carriage return, to·stop after it reaches the number of bytes I want·it to retrieve.

    PUB rxHex :Value | place, ptr, x, temp
    {{
    ·· Accepts and returns serial hexadecimal values, such as "A2F4" as a number.
    ·· String must end in a carriage return (ASCII 13)
    ·· x := Serial.rxHex···· ' accept string of digits for value
    }}··

    ··· place := 1···········································
    ··· ptr := 0
    ··· value :=0··············································
    ··· temp :=· Rx·······
    ··· if temp == -1
    ······ return -1
    ······ abort······
    ··· dataIn[noparse][[/noparse]ptr] := Temp
    ··· ptr++
    ··· repeat while (DataIn[noparse][[/noparse]ptr-1] <> 13) and (DataIn[noparse][[/noparse]ptr-1] <> Delimiter)·····················
    ····· dataIn[noparse][[/noparse]ptr] :=· Rx······························
    ····· if datain[noparse][[/noparse]ptr] == 255
    ······· return -1
    ······· abort
    ····· ptr++··········
    ··· if ptr > 1
    ····· repeat x from (ptr-2) to 0····························
    ······· if (dataIn[noparse][[/noparse]x] => ("0")) and (datain[noparse][[/noparse]x] =< ("9"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"0") * place)········
    ······· if (dataIn[noparse][[/noparse]x] => ("a")) and (datain[noparse][[/noparse]x] =< ("f"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"a"+10) * place)
    ······· if (dataIn[noparse][[/noparse]x] => ("A")) and (datain[noparse][[/noparse]x] =< ("F"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"A"+10) * place)········
    ······· place := place * 16································

    Would this work?

    PUB rxHex :Value, bytes | place, ptr, x, temp

    ··· place := 1···········································
    ··· ptr := 0
    ··· value :=0··············································
    ··· temp :=· Rx
    ····temp1 := 0
    ··· if temp == -1
    ······ return -1
    ······ abort······
    ··· dataIn[noparse][[/noparse]ptr] := Temp
    ··· ptr++
    ··· repeat·until·temp1·== (bytes·* 8)
    ····· dataIn[noparse][[/noparse]ptr] :=· Rx······························
    ····· if datain[noparse][[/noparse]ptr] == 255
    ······· return -1
    ······· abort
    ····· ptr++
    ······temp1 += 1
    ··· if ptr > 1
    ····· repeat x from (ptr-2) to 0····························
    ······· if (dataIn[noparse][[/noparse]x] => ("0")) and (datain[noparse][[/noparse]x] =< ("9"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"0") * place)········
    ······· if (dataIn[noparse][[/noparse]x] => ("a")) and (datain[noparse][[/noparse]x] =< ("f"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"a"+10) * place)
    ······· if (dataIn[noparse][[/noparse]x] => ("A")) and (datain[noparse][[/noparse]x] =< ("F"))
    ········· value := value + ((DataIn[noparse][[/noparse]x]-"A"+10) * place)········
    ······· place := place * 16································
  • VadooVadoo Posts: 92
    edited 2009-09-20 15:37
    Those SeqNum**.prp·files I posted are no good. Here is a new one that·is correct.
    I view them through http://en.webhex.net/

    Not that it matters for this part of the program but the first five bytes are configuration data used in another object later on( 1st byte # Channels, 2nd & 3rd bytes # events, 4th & 5th bytes event period in ms).
  • VadooVadoo Posts: 92
    edited 2009-09-25 03:22
    I wrote this to check the status register of a flash chip, just to test the comunication. It doesnt work. What did I do wrong?


    PUB status(Ptr) | Value, Bits·············· 'Clk pin cylce speed is waitcnt((clkfreq/100000) + cnt)
    ··· dira[noparse][[/noparse]SO]~
    ··· dira[noparse][[/noparse]SI]~~····································
    ··· dira[noparse][[/noparse]CLK]~~··································
    ··· outa[noparse][[/noparse]CLK]~····································
    ··· dira[noparse][[/noparse]CS]~~
    ··· outa[noparse][[/noparse]CS]~~
    ··· waitcnt(clkfreq/50000 + cnt)
    ··· outa[noparse][[/noparse]CS]~····································· 'Set Chip Select Low
    ··· waitcnt(clkfreq/50000 + cnt)
    ··· Value := %00000101···························· 'Check Status Register Command (05h)
    ··· Value <<= (32 - 8)···························· 'pre-align msb
    ··· repeat 8······································
    ········ outa[noparse][[/noparse]SI] := (Value <-= 1) & 1············ 'output data bit
    ········ PostClock································ 'Cycle Clock pin high/low
    ··· repeat 8······································ 'Get Serial Input
    ········ PreClock································· 'Cycle Clock pin high/low
    ········ Ptr := (Ptr << 1) | ina[noparse][[/noparse]SO]·············· 'Store Serial input to Ptr
    ·· waitcnt(clkfreq/50000 + cnt)
    ·· outa[noparse][[/noparse]CS]~~····································· 'Set Chip Select High


    PUB PostClock
    ··· waitcnt((clkfreq/100000) + cnt)
    ··· outa[noparse][[/noparse]CLK]~~
    ··· waitcnt((clkfreq/100000) + cnt)
    ··· outa[noparse][[/noparse]CLK]~
    PUB PreClock
    ··· outa[noparse][[/noparse]CLK]~~
    ··· waitcnt((clkfreq/100000) + cnt)
    ··· outa[noparse][[/noparse]CLK]~
    ··· waitcnt((clkfreq/100000) + cnt)

    ···
  • VadooVadoo Posts: 92
    edited 2009-09-26 21:45
    Does anyone have any ideas why my code wont work?
  • hover1hover1 Posts: 1,929
    edited 2009-09-26 23:09
    Could you·post an attachment in a .spin or .zip archive that would be readable?

    ·.hlx does not·register as a valid Parallax format.

    Jim
    Vadoo said...
    Does anyone have any ideas why my code wont work?
  • VadooVadoo Posts: 92
    edited 2009-09-27 00:15
    The .HLX can be viewed·through http://en.webhex.net/

    It is the file to be read containing binary intensity values for the shift register.

    I have stopped trying to read it for the moment. I am trying to make it a lot more simple to start out, and just read the status register, so I know if communication is working with the flash chip. So far I cant get any response, I dont know what Im doing wrong.
  • KyeKye Posts: 2,200
    edited 2009-09-27 01:25
    I would do the communication like this:
    PUB getRegisterValue(register) ' Reuturns register value.
     
      outa[noparse][[/noparse]cs]~
     
      register <<= 24
     
      repeat 8
        value <-= 1
        outa[noparse][[/noparse]si] := value
        outa[noparse][[/noparse]clk]~~
        outa[noparse][[/noparse]clk]~
     
      repeat 8
        outa[noparse][[/noparse]clk]~~
        outa[noparse][[/noparse]clk]~
        result |= ina[noparse][[/noparse]so]
        result <<= 1
             
      outa[noparse][[/noparse]cs]~~                             
     
    PUB startup ' Run once.
     
      dira[noparse][[/noparse]so]~
      dira[noparse][[/noparse]si]~~
      dira[noparse][[/noparse]clk]~~
      dira[noparse][[/noparse]cs]~~
     
      outa[noparse][[/noparse]clk]~
      outa[noparse][[/noparse]cs]~~
     
    PUB getStatus ' Returns the status.
     
      return getRegisterValue($05)
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • VadooVadoo Posts: 92
    edited 2009-09-27 03:06
    I called it with

    temp := SPI.getstatus

    Im still not getting a reply.

    What·is register <<= 24 for?
  • KyeKye Posts: 2,200
    edited 2009-09-27 15:06
    Opps, that code is wrong.

    PUB getRegisterValue(register) ' Reuturns register value.
     
      outa[noparse][[/noparse]cs]~
     
      register ><= 8
     
      repeat 8
        outa[noparse][[/noparse]si] := register
        register >>= 1 
        outa[noparse][[/noparse]clk]~~
        outa[noparse][[/noparse]clk]~
     
      repeat 8
        outa[noparse][[/noparse]clk]~~ 
        outa[noparse][[/noparse]clk]~
        result |= ina[noparse][[/noparse]so]
        result <<= 1
             
      outa[noparse][[/noparse]cs]~~                             
     
    PUB startup ' Run once.
     
      dira[noparse][[/noparse]so]~
      dira[noparse][[/noparse]si]~~
      dira[noparse][[/noparse]clk]~~
      dira[noparse][[/noparse]cs]~~
     
      outa[noparse][[/noparse]clk]~
      outa[noparse][[/noparse]cs]~~
     
    PUB getStatus ' Returns the status.
     
      return getRegisterValue($05)
    
    


    I don't know if I'm doing the chip selects right. You should look up the exact timing spec for the chip you are communicating to.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.