Debugging: Propchip, VMusic2, Atmel 64Megabit Flash, 16bit Shiftregister
Vadoo
Posts: 92
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.
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
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,
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.
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.
That statement from Kye only made me think of ways to abuse volunteers
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BH
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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)??????
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,
"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.
(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,
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································
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).
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)
···
·.hlx does not·register as a valid Parallax format.
Jim
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
temp := SPI.getstatus
Im still not getting a reply.
What·is register <<= 24 for?
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,