Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : uM2(+): data logging - cheap fast & easy
Page 3 of 6 | |||||
Author | Message | ||||
Zonker Guru Joined: 18/08/2012 Location: United StatesPosts: 761 |
Is there a way to use these chips to store pictures of other types of data that could be used as resource data for the LCD displays..? |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
@ matherp - Great, thanks. I hope to get a chip wired up this weekend and play about with it. Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
I can't get the test code(matherp's MM+ code) to respond past this point: You have to press hardware-reset to recover - CTRL+C does not work. My instinct is telling me that the JDEC ID being FFFFFF means perhaps no response from the SPI chip? EDIT: Also, this chip(W25Q80BV) should be getting ID'd as 8Mbit, not 16Mbit.... CS pin is correct - 14 in this case, and yes, changed line 4 to reflect that. I have fitted a chip to a 5" LCD module, in the spare footprint, and connected F_CS to pin14 of the MM+. The problem might be that F_CS is connected to 3v3 at the moment, so I knew that pulling CS low would short out the power supply via the MM when pin14 goes low, so I have a 4k7 in series with pin14. However, this is probably where the root of my problem is, yes? The MM+ cannot pull the CS line low enough, with a direct connection to 3v3 on the CS pin, and 4k7 to pin14 on the MM+, correct? F_CS is on an internal layer of the controller PCB which is four-layer, so cutting the direct connection to 3v3 on F_CS is difficult - hence the 4k7 in the pin14 side of things, but I think this is making the SPI chip deaf as a post to the MM+ trying to pull CS low, personally. Any comments, suggestions, confirmation of my thoughts etc welcomed. Smoke makes things work. When the smoke gets out, it stops! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8583 |
????? Not on any display I've tried (3.2", 4.3", 5", 7") |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Sorry if my post was confusing. The controller board that the LCD plugs into, is a four-layer board, and one of the internal layers of that board, connect F_CS to 3v3. I have run out of brain-power tonight, as it is 3:45AM, but tomorrow, I will hook up an Explore64 module to the LCD with jumper wires, which will allow me to get access to the SPI memory chip without the other controller board with the internal layer connection, which I am pretty sure must be what is stuffing things up. I was just hoping to use a board I already had made, but that is not going to be the case. No biggie - will post another update tomorrow. Smoke makes things work. When the smoke gets out, it stops! |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Could you maybe unsolder the CS pin and bent it up slightly so that it does not connect to the pcb anymore and a wire directly to the uMite pin? Maybe put some foil under the pin to prevent contact? A 'hack' but easy enough to try. Microblocks. Build with logic. |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1094 |
G, If the CS pin is tied directly to 3.3V then a 4k7 resistor to the MM pin won't be any good whatsoever as all you will do is drop 3.3V across the resistor when the MM pulls the line low - CS will still have 3.3V on it! panky ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Yeah, pretty much what I was thinking too. No matter WHAT you do, with CS tied directly high, you can't ever pull it low enough to make it respond, so it stays deaf to commands forever. I hope to do a quick wire-up without the 4-layer board tonight. Just the LCD module, and wired to an Explore64 module. Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Yep, that was the problem...... I'm impressed with the demo program - 1000 records written to the SPI memory in five seconds. 200 per second! That's really quite impressive on the speed. I don't think you would have a hope of getting that kind of speed out of I2C would you? Even at 400kHz. I know there are high-speed I2C EEPROM's now, but my new love in memory is SPI type. Wow. The tinkering begins........ Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
QUESTION: When using writepage, does the string HAVE to be 256 bytes long? If I try writing some data to any page, I am getting serious data corruption when I try to read it back. Example: A$="000_ABCDEFGH" writepage (100,A$,21) That completes with no errors reported. readpage (100,A$,21) This does not return the results in A$. I am trying to follow the example code, but it is complicated - to me, that is.... To gurus like matherp, it is probably very simple, but I can't follow a lot of what is going on in the routines. Especially in readlog around databuffer buff. Why are you reading two pages at a time? How come those pages only seem to be 32 bytes each when the pages are 256 bytes? Lost..... From what I can see, buff just holds the raw data from the page, and then the string is being read out of that buffer(into s$ in the examples), and then you print THAT. The syntax as you need to pass to the Cfunctions would be really useful at this point, as the MM+ version does not comment this in the code, whereas the first version on page 1 of this thread does. Can anyone give me any pointers? An example of what I want to do: 1) Any string I want, gets saved to any page I choose using writepage. 2) The string can be any length(up to 256 bytes), but normally is 12 bytes. 3) Each string needs to be in it's own page, NOT amended to another string on the same page. 4) Read back that data using the readpage command, so I can read any page at any time - Random-access. I don't care about unused bytes on any one page with respect to step 3 - the chip has tons of space. readpage is confusing me, as I don't understand how the buffer and readstring concept needs to work together. My brain is simply saying that READPAGE (100,A$,21) should read the contents of page 100 into A$(with CS on pin21) and then I can do whatever I want with it - this is obviously not how it works though. Can I pester matherp for a little more information on how I would change things to do what I am trying to do? Smoke makes things work. When the smoke gets out, it stops! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8583 |
From my earlier answer to you: Otherwise when you read you are trampling over other MMBasic variables 32 integers @ 64-bits long == 256 bytes @ 8-bits long Because I'm packing the strings (which in my usage can be variable length) and a string may start in one page and end in a second |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1133 |
Hi Peter, thank you again, your code works like a charm! I use a MX170/28PIN/48MHz (Micks Backpack170) + W25Q64FVSSIG (8MB) and I needed only to make one very little modification. Sub formatlog(cspin As integer) 'erase the chip and set up the page index
Local integer i,bytecount,r(2) Local s$ length 10 Timer=0 SPI open 20000000,3,8 Pause 100 bytecount = getpagecount(s$,cspin)*256 gives me this: JEDEC ID = EF4017
Memory size is 64 Mbits = 8388608 Bytes Format complete! Time: 17.837 1,000 records constructed and logged in 7 seconds 01-01-2000,02:11:41,one 01-01-2000,02:11:41,two 01-01-2000,02:11:41,three 01-01-2000,02:11:41,four 01-01-2000,02:11:41,five 01-01-2000,02:11:41,six without the PAUSE command I got something like this (after a rerun): JEDEC ID = FFFFFF
Memory size is 16384 Mbits = 2147483648 Bytes My MX170/28 connections (CS=24) ' pin 1 (chip select) - connect to any Micromite output capable pin MM-24 ' pin 2 (Data out) - connect to the SPI-IN pin on the Micromite MM-14 ' pin 3 (write protect) - 10K resistor to 3.3V MM-VCC (10k) ' pin 4 (GND) - connect to ground MM-8 (GND) ' pin 5 (Data in) - connect to the SPI-OUT pin on the Micromite MM-3 ' pin 6 (Clock) - connect to the SPI-CLK pin on the Micromite MM-25 ' pin 7 (Hold) - 10K resistor to 3.3V MM-VCC (10k) ' pin 8 (VCC) - connect to 3.3V MM-13 (VCC) Regards Michael EDIT Thanks also to Grogster, MB, ... and the other guys here, they made things much clearer. EDIT2 Read benchmark: >200KB/s (AFAICS) Thats not bad! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Ahhhh - I see, and I remember you saying that now. Sorry. 32 integers @ 64-bits long == 256 bytes @ 8-bits long Okey dokey, I see that now. Thanks. Because I'm packing the strings (which in my usage can be variable length) and a string may start in one page and end in a second OK. I will play with some strings of 255 bytes in length, and let you know what happens. Smoke makes things work. When the smoke gets out, it stops! |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
21 mill DIL IC ..... and they actually sold one too! I'm in the wrong game! My latest offer is a 100pin WiFi controlled MicroMite for just $1M (or two for $1.5M). Bargain compared to this other guy . . . (how do people get away with this??) EDIT: And delivery is 15-26 days for this guy - I would personally deliver within 48hours for this price!! For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
akashh Senior Member Joined: 19/01/2014 Location: IndiaPosts: 115 |
Has anyone implemented a FAT file system on one of these? It should not be too difficult to adapt the c FAT code already developed for that application. |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
matherp - I cannot make these routines work when separated from your example code. Trying to call WRITEPAGE crashes the MM+ and I have to press reset - CTRL-C does not get me out of this issue. Initial test code ran first, and that completes fine, and reads back fine, so I know that the MM+ is indeed talking to the SPI memory. My test code is: ...and the results are: Note that I am building a string with a length of 255 bytes to write to the SPI memory with the writepage sub. This is shown on the console. As soon as I issued the writepage command, the MM+ crashes. Can you offer any reason for this? Smoke makes things work. When the smoke gets out, it stops! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8583 |
I've no idea what you are doing wrong but the attached is a simple example of direct page read/write (MM+, SPI2 version). option explicit
option default none dim integer i const chipselectpin%=21 'chip select pin dim s$ ' ' Example program to demonstrate logging to a serial flash chip mounted on a SSD1963 ' Compatible with 64 and 100 pin MM+ processors ' testdata() 'sets up the testdata generator ' formatlog(chipselectpin) 'format the chip ' timer=0 for i=1 to 1000 'log 1,000 strings s$=int2Text(i) s$=s$+space$(255-len(s$)) writepage(i,s$,chipselectpin%) next i print "1,000 records constructed and logged in ",timer\1000," seconds" pause 3000 for i=1 to 1000 'log 1,000 strings readpage(i,s$,chipselectpin%) print s$ next i ' end ' '**************************************** ' ' sub formatlog(cspin as integer) 'erase the chip and set up the page index local integer i,bytecount,r(2) local s$ length 10 bytecount = getpagecount(s$,cspin)*256 print "JEDEC ID = ",s$ print "Memory size is ",bytecount\131072," Mbits" if not (erasechip(bytecount,cspin)) then print "erase failed" end endif for i=0 to bytecount\524288 setpagewritten(i,cspin) 'mark the index pages and first real page as used next i print "Format complete" end sub ' sub writelog(s$,cspin as integer,timestamp as integer) 'write a string to the next location on the chip with optional timestamp local integer i,x,buff(63),f,pagecount local d$ length 10 pagecount=getpagecount(d$,cspin) x=getnextfreepage(pagecount,cspin) if x < pagecount-1 then if x<>pagecount\2048 then x=x-1 'point to the previous page to see if it has space readpage(x,buff(0),cspin) 'read in first page readpage(x+1,buff(32),cspin) 'read in the second page f=getfirstfreebyte(buff()) if timestamp then i=loadstring(date$+","+time$+","+s$,buff(),f) else i= loadstring(s$,buff(),f) endif if i>=256 then 'write the bit on the next page and set the page marker as used writepage(x+1,buff(32),cspin) setpagewritten(x+1,cspin) endif writepage(x,buff(0),cspin) else print "Error: Chip full" endif end sub ' sub readlog(cspin as integer) 'read and print the log local integer x,buff(63),f=0, n,i local s$ x=getpagecount(s$,cspin)\2048 'number of indexpages readpage(x,buff(0),cspin) 'read in first two pages readpage(x+1,buff(32),cspin) if buff(0) =-1 then exit sub 'no data endif n=getstring(s$, buff(0),f) print s$ do while n<>&HFF 'repeat until no more data if f>=256 then x=x+1 readpage(x,buff(0),cspin) 'read in next two pages readpage(x+1,buff(32),cspin) f=f-256 endif n=getstring(s$, buff(0),f) print s$ loop end sub ' sub setpagewritten(pageno as integer, cspin as integer) 'set a page as partially or completely written local integer buff(31),i local integer mappage=pageno\2048 'we have 2048 bits per page local integer wordno=(pageno-mappage*2048)\64 'locate the word in the page local integer bitno= 1<<(pageno mod 64) 'locate the bit in the word in the page readpage(mappage,buff(),cspin) buff(wordno) =buff(wordno) XOR bitno writepage(mappage,buff(),cspin) end sub ' CFunction getnextfreepage 00000000 27BDFEC8 AFB7012C AFBF0134 AFBE0130 AFB60128 AFB50124 AFB40120 AFB3011C AFB20118 AFB10114 AFB00110 8C830004 8C820000 8CB60000 000327C3 308407FF 00821021 0044B82B 02E3B821 000212C2 0017BD40 02E2B825 24030001 3C02BF80 AC435A30 1AE00048 0000A021 3C159D00 3C10BF80 241E0003 27B20110 24130020 8EA2001C 02C02021 0040F809 24050005 00141A00 AE1E5A20 8E025A10 30420080 1040FFFD 7C623C00 8E045A20 AE025A20 8E025A10 30420080 1040FFFD 7C623A00 8E045A20 AE025A20 8E025A10 30420080 1040FFFD 00000000 306300FF 8E025A20 AE035A20 8E025A10 30420080 1040FFFD 00000000 8E025A20 27A30010 AE115A20 8E025A10 30420080 1040FFFD 00000000 8E115A20 7C118C20 A0710000 24630001 1472FFF6 02C02021 8EA2001C 0040F809 24050006 8FA20010 8FA30014 00431025 14400012 00002021 27A20018 24040001 8C430000 8C450004 00651825 1460000B 24420008 24840001 5493FFFA 8C430000 26940001 0297102A 5440FFC2 8EA2001C 10000002 24040100 00002021 27A30010 000410C0 00621021 8C460000 8C450004 30C30001 14600011 00001021 24020001 00055840 240A0040 00024827 00461806 012B4804 30480020 00453807 01231825 00E8180B 30630001 54600005 0014A140 24420001 144AFFF5 00024827 0014A140 02842021 8FBF0134 00042180 00441021 00021FC3 8FBE0130 8FB7012C 8FB60128 8FB50124 8FB40120 8FB3011C 8FB20118 8FB10114 8FB00110 03E00008 27BD0138 End CFunction ' CFunction getpagecount 00000000 27BDFFC8 AFB30028 AFBF0034 AFB50030 AFB4002C AFB20024 AFB10020 AFB0001C 8CB10000 3C029D00 8C420088 00111880 00621021 8C420000 24030008 10430007 00809821 3C029D00 8C420010 02202021 24050008 0040F809 00003021 3C02BF81 8C44F220 3C029D00 8C430088 3C020580 7C84D800 3442B053 00821026 24050014 24040030 00A2200B 00831021 8C430000 24020065 1062006F 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 24040005 2403000C 0065200A 00003021 0040F809 24050008 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 24040005 2403000C 0065200A 00003021 0040F809 24050064 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 2404002F 2403000B 0065200A 00003021 0040F809 24050002 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 2404002F 2403000B 0065200A 00003021 0040F809 24050064 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 24040004 2403000A 0065200A 00003021 0040F809 24050008 3C02BF81 8C45F220 3C030580 3C029D00 8C420010 3463B053 7CA5D800 00A32826 24040004 2403000A 0065200A 00003021 0040F809 24050064 3C02BF81 8C43F220 3C020580 3442B053 7C63D800 1462000C 3C03BF81 8C64FA90 24050001 3C02BF81 7CA41804 AC64FA90 8C43FCA0 24040006 7C831804 AC43FCA0 1000000B 3C029D00 8C64FA90 24050007 3C02BF81 7CA41804 AC64FA90 8C43FC9C 24040006 7C831804 AC43FC9C 3C029D00 8C42001C 02202021 0040F809 24050006 3C02BF80 34038060 24040C00 AC435A00 AC445A40 24040001 AC445A30 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C029D00 8C42001C 3C10BF80 02202021 24050005 8E125A20 0040F809 00000000 2402009F AE025A20 3C03BF80 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C505A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C555A20 3C03BF80 AC525A20 8C625A10 30420080 1040FFFD 3C129D00 8E42001C 3C03BF80 02202021 24050006 8C745A20 0040F809 00108200 24020010 AFA20010 02158021 8E420030 00108200 02148021 26640001 02003021 0040F809 00103FC3 3C02FF40 3442D9BF 02021021 24030006 2C420002 10400027 A2630000 3C029D00 8C42001C 02202021 0040F809 24050005 24030006 3C02BF80 AC435A20 3C03BF80 8C625A10 30420080 1040FFFD 3C129D00 8E42001C 3C13BF80 02202021 24050006 8E635A20 0040F809 00000000 8E42001C 02202021 0040F809 24050005 24020098 AE625A20 3C03BF80 8C625A10 30420080 1040FFFD 3C029D00 8C42001C 3C03BF80 02202021 24050006 8C635A20 0040F809 00000000 3C0200BF 24422642 24044000 12020012 00002821 3C0200BF 24422602 1202000E 3C0200BF 24422641 1202000B 24042000 3C0200BF 24422601 12020006 2694FFF8 24020001 0282A004 02802021 10000002 00142FC3 00002821 8FBF0034 00801021 00A01821 8FB50030 8FB4002C 8FB30028 8FB20024 8FB10020 8FB0001C 03E00008 27BD0038 End CFunction ' CFunction erasechip 00000000 27BDFFD8 AFB40020 AFB00010 AFBF0024 AFB3001C AFB20018 AFB10014 8CB30000 3C029D00 8C42001C 24030001 3C10BF80 AE035A30 0080A021 24050005 0040F809 02602021 24020006 AE025A20 3C03BF80 8C625A10 30420080 1040FFFD 3C109D00 8E02001C 3C11BF80 02602021 24050006 8E235A20 0040F809 00000000 8E02001C 02602021 0040F809 24050005 240200C7 AE225A20 3C03BF80 8C625A10 30420080 1040FFFD 3C029D00 8C42001C 02602021 24050006 3C03BF80 8C635A20 0040F809 3C119D00 3C10BF80 8E220004 0040F809 3404C350 8E22001C 02602021 0040F809 24050005 24020005 AE025A20 8E025A10 30420080 1040FFFD 00000000 8E025A20 AE125A20 8E025A10 30420080 1040FFFD 00000000 8E125A20 8E22001C 02602021 7C129420 0040F809 24050006 32420001 5440FFE6 8E220004 3C029D00 8C42001C 02602021 0040F809 24050005 24030003 3C02BF80 AC435A20 3C03BF80 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 00000000 8E820004 3C03BF80 8C635A20 5C400006 3C02BF80 14400014 3C029D00 8E820000 10400010 3C02BF80 AC525A20 3C03BF80 8C625A10 30420080 1040FFFD 3C029D00 8C42001C 02602021 24050006 3C03BF80 8C635A20 0040F809 00000000 10000007 00001021 3C029D00 8C42001C 02602021 0040F809 24050006 24020001 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0028 End CFunction ' Csub writepage 00000000 27BDFFD8 AFB3001C AFB10014 AFB00010 AFBF0024 AFB40020 AFB20018 8CD30000 3C029D00 8C42001C 8C940000 24030001 3C11BF80 AE235A30 00A08021 02602021 0040F809 24050005 24020006 0014A200 AE225A20 3C03BF80 8C625A10 30420080 1040FFFD 3C119D00 8E22001C 3C12BF80 02602021 24050006 8E435A20 0040F809 00000000 8E22001C 02602021 0040F809 24050005 24020002 AE425A20 3C03BF80 8C625A10 30420080 1040FFFD 3C02BF80 7E843C00 8C435A20 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD 3C02BF80 7E943A00 8C435A20 3C03BF80 AC545A20 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C425A20 00002021 3C03BF80 240500FF 02041021 80420000 AC625A20 8C625A10 30420080 1040FFFD 00000000 8C625A20 10850003 3C029D00 1000FFF5 24840001 8C42001C 02602021 0040F809 24050006 24120100 3C119D00 3C10BF80 8E220004 0040F809 240400FA 8E22001C 02602021 0040F809 24050005 24020005 AE025A20 8E025A10 30420080 1040FFFD 00000000 8E025A20 AE125A20 8E025A10 30420080 1040FFFD 00000000 8E125A20 8E22001C 02602021 0040F809 24050006 32420001 5440FFE7 8E220004 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0028 End Csub ' Csub readpage 00000000 27BDFFD8 AFB3001C AFB20018 AFB10014 AFBF0024 AFB40020 AFB00010 8CD20000 3C029D00 8C42001C 8C940000 24030001 3C13BF80 AE635A30 00A08821 02402021 0040F809 24050005 24020003 0014A200 AE625A20 3C03BF80 8C625A10 30420080 1040FFFD 3C02BF80 7E843C00 8C435A20 3C03BF80 AC445A20 8C625A10 30420080 1040FFFD 3C02BF80 7E943A00 8C435A20 3C03BF80 AC545A20 8C625A10 30420080 1040FFFD 3C02BF80 8C435A20 3C03BF80 AC405A20 8C625A10 30420080 1040FFFD 3C02BF80 8C425A20 00002021 3C03BF80 24050100 AC705A20 8C625A10 30420080 1040FFFD 00000000 8C705A20 02241021 24840001 7C108420 1485FFF6 A0500000 3C029D00 8C42001C 02402021 0040F809 24050006 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0028 End Csub ' CFunction getfirstfreebyte 00000000 90830000 240200FF 00003021 10620014 00003821 90830001 1062000A 24020001 24020002 240500FF 24080100 00821821 90630000 54650006 24420001 10000002 00403021 00403021 10000005 00023FC3 5448FFF7 00821821 24060100 00003821 00C01021 03E00008 00E01821 End CFunction ' CFunction loadstring 00000000 8CC30000 90820000 00621021 0043302A 14C0000A 24660001 00A31821 90870000 24C60001 24C5FFFF 0045282A A0670000 24840001 10A0FFF9 24630001 03E00008 00021FC3 End CFunction ' CFunction getstring 00000000 8CC20000 00A21821 90690000 01224821 0122182A 5460000C 25220001 24430001 00A21021 90480000 24630001 2467FFFF 0127382A A0880000 24420001 10E0FFF9 24840001 25220001 00021FC3 ACC30004 ACC20000 00A92821 90A20001 03E00008 00001821 End CFunction ' '**************************** ' test data generation ' 'small sub testdata DATA "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" DATA "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" 'tens DATA "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" 'big DATA "thousand", "million", "billion" dim small(19) AS STRING length 10, tens(7) AS STRING length 10, big(2) AS STRING length 10 FOR i = 1 TO 19 READ small(i) NEXT FOR i = 0 TO 7 READ tens(i) NEXT FOR i = 0 TO 2 READ big(i) NEXT ' end sub . FUNCTION int2Text(number AS integer) as string local num AS integer, outP AS STRING length 60, unit AS INTEGER local tmpLng1 AS integer IF 0 = number THEN int2Text = "zero" EXIT FUNCTION END IF num = ABS(number) DO tmpLng1 = num MOD 100 SELECT CASE tmpLng1 CASE 1 TO 19 outP = small(tmpLng1) + " " + outP CASE 20 TO 99 SELECT CASE tmpLng1 MOD 10 CASE 0 outP = tens((tmpLng1 \ 10) - 2) + " " + outP CASE ELSE outP = tens((tmpLng1 \ 10) - 2) + "-" + small(tmpLng1 MOD 10) + " " + outP END SELECT END SELECT tmpLng1 = (num MOD 1000) \ 100 IF tmpLng1 THEN outP = small(tmpLng1) + " hundred " + outP END IF num = num \ 1000 IF num < 1 THEN EXIT DO tmpLng1 = num MOD 1000 IF tmpLng1 THEN outP = big(unit) + " " + outP unit = unit + 1 LOOP IF number < 0 THEN outP = "negative " + outP Do WHILE ASC(RIGHT$(outp,1))<=32 outp = LEFT$(outp,len(outp)-1) loop int2Text = outP END FUNCTION '********************************* |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Cheers, I will try that out and get back to you. With the above example of mine in mind, and bearing that it is 255 bytes long, can you state if my method at the command line SHOULD be working but isn't, or do you happen to think that this would not work anyway? IE: Can the Csub's for read and write be run from the command line? Perhaps they have to be inside a running code - I have not tried that, so I will also test that theory. I believe that I have the command syntax correct, and D$ in my example is 255 bytes long, so that should keep the CSub happy, I would have thought..... EDIT: I found something. By changing your example code line-by-line, I have found that inserting my code example into your loops works, and reads back. The key is that if you DON'T allow formatlog on line 12 to run EVERY time you run the code, the writepage routine crashes the MM+. If you let formatlog run as part of the code, then it works, but I can't have the code erasing the chip everytime you want to write something to it. Comment-out line 12, and run the code you sent me - you will see what I mean. Do you have any idea why the writepage CSub would care about the formatlog routine needing to be a prerequisite? Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Here are some screenshots. My code changes: The result of four write/reads: Now, if I comment-out line 12: Smoke makes things work. When the smoke gets out, it stops! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8583 |
The SPI channel needs to be open to use read and write page commands. This is normally done if a TFT display has been enabled (OPTION LCDPANEL ...) or if you call getpagecount. If not you need to explicitly open the SPI channel. In the case of the example you could do this with SPI2 open 10000000,3,8 The assumption was that any program would call getpagecount so you know what size flash you are using |
||||
Page 3 of 6 |
Print this page |