View previous topic :: View next topic |
Author |
Message |
Twenty
Joined: 30 Nov 2004 Posts: 50 Location: Sydney
|
Posted: Thu Jun 02, 2011 3:33 am Post subject: Errors with main.bas program |
|
|
If I compile the main.bas program as provided with AN186 I get the following errors:
Error : 46 Line : 4 Assignment error [SDYEAR: 0 2011: 112] , in File : Example_WIPE.bas
Error : 46 Line : 5 Assignment error [SDMONTH: 0 5: 112] , in File : Example_WIPE.bas
Error : 7 Line : 0 IF THEN expected [ 5] , in File :
Error : 123 Line : 0 END IF expected , in File :
I get similiar errors if "Example_FIND_READ_FILE.bas" is selected in the main program
Bascom version: 2060 Full
Any help would be appreciated |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Mon Jun 06, 2011 10:31 am Post subject: |
|
|
Hi Twenty
Could you please post your "developer switches" from include file KokkeKat_FAT-free_SD_lib_decl.bas?
The errors suggest that the data declarations are not complete.
Kind regards
Niclas |
|
Back to top |
|
|
Twenty
Joined: 30 Nov 2004 Posts: 50 Location: Sydney
|
Posted: Mon Jun 20, 2011 12:21 am Post subject: |
|
|
Hi Niclas,
Developer switches as follows:
' Developer switches:
' 1 = minimum detail (only make sure that the init is successful)
' 0 = full detail (return full detail if init is unsuccessful)
Const Sdinitdetail = 1
' 1 = FAT16/32 file system active
' 0 = FAT16/32 file system not active (only read and write raw sectors)
Const Sdfsactive = 1
' 1 = Use the FIND routine
' 0 = Don't use the FIND routine
Const Sdusefind = 1
' 1 = Enable Sdusefindstoreentry
' 0 = Don't enable Sdusefindstoreentry
Const Sdusefindstoreentry = 1
' 1 = Use Sddirlist
' 0 = Don't use Sddirlist
Const Sdusedirlist = 1 ' Use or don't use
Const Sddirlistarraysize = 12 ' If used, set the size of the array that holds the cluster numbers
' 1 = read
' 0 = not reading
Const Sdrmode = 1
' 2 = write unbuffered
' 1 = write buffered
' 0 = not writing
Const Sdwmode = 0
' 1 = Use Sdappend
' 0 = Don't use Sdappend
Const Sduseappend = 0
' 1 = Clear the unused end of the sector before writing it to the SD card
' 0 = Don't clear the unused end of the sector before writing it to the SD card
Const Sdcleartail = 0
' 1 = Use FAT32 fsinfo sector data
' 0 = Don't use FAT32 fsinfo sector
Const Sdusefsinfo = 0
' 1 = Use Long FileNames when reading
' 0 = Don't use Long FileNames when reading
Const Sduselfn = 1
' 1 = When using lfn, also support file name comparison
' 0 = When using lfn, don't support file name comparison
Const Sduselfncompare = 0
' 1 = Use wipe
' 0 = Don't use wipe
Const Sdusewipe = 0
' 1 = Use the size info routine
' 0 = Don't use the size info routine
Const Sdusesizeinfo = 1
' 1 = Use the CRC7 function
' 0 = Don't use the CRC7 function
Const Sdusecrc7 = 0 ' This has no practical use in the library - use it if you want to add CRC7 checks yourself
I have selected the "find read file" option in the main .bas file. I now get the following error when compiling:
Error : 60 Line : 2659 Duplicate label [SDCHECKCLUSTERREFERENCE ] , in File : KokkeKat_FAT-free_SD_lib_code.bas
Thanks for your help
Regards |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Sun Jun 26, 2011 7:26 pm Post subject: |
|
|
Hi Twenty
Sorry for my late replies. You have managed to post questions on the first day of both my last two vacations.
The error messages appear because you have chosen both Const Sdusefind = 1 and Const Sdusedirlist = 1.
Sdusedirlist enables the "forward and backward scrolling", which (apart from listing the directory content) also allows you to look for a matching file or directory name.
Sdusefind cannot list the directory content, but it requires less program space.
In other words, you use either one of them - not both. I should have been more clear in my instructions.
I hope this solves your problem.
Kind regards
Niclas |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Tue Jun 28, 2011 5:04 am Post subject: Complie errors |
|
|
Hello Niclas,
Like the previous poster, I am having compile problems. In my main routine, i have selected "Example Find Read File.bas" and my developer switches are here. I get a bunch of error codes, which I don't understand, and of course the line numbers dont exist.
regards
neil
' Developer switches:
'--------------------------------------------------------------
' 1 = minimum detail (only make sure that the init is successful)
' 0 = full detail (return full detail if init is unsuccessful)
Const Sdinitdetail = 1
'---------------------------------------------------------------
' 1 = FAT16/32 file system active
' 0 = FAT16/32 file system not active (only read and write raw sectors)
Const Sdfsactive = 1
'----------------------------------------------------------------
' 1 = Use the FIND routine
' 0 = Don't use the FIND routine
Const Sdusefind = 1 'cant use when Sdusedirlist =1
'----------------------------------------------------------------
' 1 = Enable Sdusefindstoreentry
' 0 = Don't enable Sdusefindstoreentry
Const Sdusefindstoreentry = 0
'---------------------------------------------------------------
' 1 = Use Sddirlist
' 0 = Don't use Sddirlist
Const Sdusedirlist = 0 ' Use or don't use. See FIND routine above
'-----------------------------------------------------------------
Const Sddirlistarraysize = 12 ' If used, set the size of the array that holds
' 'the cluster numbers
'-----------------------------------------------------------------
' 1 = read
' 0 = not reading
Const Sdrmode = 1
'------------------------------------------------------------------
' 2 = write unbuffered
' 1 = write buffered
' 0 = not writing
Const Sdwmode = 0
'------------------------------------------------------------------------
' 1 = Use Sdappend
' 0 = Don't use Sdappend
Const Sduseappend = 1
'------------------------------------------------------------------------
' 1 = Clear the unused end of the sector before writing it to the SD card
' 0 = Don't clear the unused end of the sector before writing it to the SD card
Const Sdcleartail = 0
'------------------------------------------------------------------------
' 1 = Use FAT32 fsinfo sector data
' 0 = Don't use FAT32 fsinfo sector
Const Sdusefsinfo = 0
'------------------------------------------------------------------------
' 1 = Use Long FileNames when reading
' 0 = Don't use Long FileNames when reading
Const Sduselfn = 0
'------------------------------------------------------------------------
' 1 = When using lfn, also support file name comparison
' 0 = When using lfn, don't support file name comparison
Const Sduselfncompare = 0
'------------------------------------------------------------------------
' 1 = Use wipe
' 0 = Don't use wipe
Const Sdusewipe = 0
'------------------------------------------------------------------------
' 1 = Use the size info routine
' 0 = Don't use the size info routine
Const Sdusesizeinfo = 0
'------------------------------------------------------------------------
' 1 = Use the CRC7 function
' 0 = Don't use the CRC7 function
Const Sdusecrc7 = 0 ' This has no practical use in the library - use it if you want to add CRC7 checks
Here are the compile errors:
Error : 211 Line : 77 External routine not found [_GETFILEHANDLE] , in File : C:\bascom8.2\projects\nb.bas
Error : 211 Line : 77 External routine not found [_FILEWRITESTRCONST] , in File : C:\bascom8.2\projects\nb.bas
Error : 211 Line : 77 External routine not found [_FILEWRITECRLF] , in File : C:\bascom8.2\projects\nb.bas
Error : 211 Line : 77 External routine not found [_FILEWRITEDECBYTE] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_GETFILEHANDLE ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_FILEWRITESTRCONST ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_FILEWRITECRLF ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_GETFILEHANDLE ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_FILEWRITESTRCONST ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_FILEWRITEDECBYTE ] , in File : C:\bascom8.2\projects\nb.bas
Error : 61 Line : 77 Label not found [_FILEWRITECRLF ] , in File : C:\bascom8.2\projects\nb.bas
'=============================================================================== _________________ Neil |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Tue Jun 28, 2011 8:53 am Post subject: |
|
|
Hi Neil
Hmmm, I don't recognize the labels and routines mentioned in your error messages. For example, my SD lib doesn't use file handles. Are you perhaps mixing my lib with AVR-DOS, the other FAT32 library?
If that's not the case, my best advice is to go back to the demo example, using only the files included in the download. Please let me know if you still have problems after this.
Kind regards
Niclas |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Tue Jun 28, 2011 10:29 pm Post subject: |
|
|
Thanks Noiclas. that gave me athe clue I needed, and it was very simple. I had forgotten to config my serial port and a call to Print #1 in place of your 3310 display was causing the weird error msgs. I now have the scroll_LFN.bas succesfully compiled, but it is hanging on the line where Sd_cs is set high, in ...SD_lib_code.bas. I'm working on it now. will report back.
thanks for your prompt reply
neil _________________ Neil |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Wed Jun 29, 2011 6:44 am Post subject: |
|
|
Hello again Niclas,
Well today I managed to get your Demo_scroll.bas running more or less, and i can read a card formated in my NIKON camera. I spent a lot of time working out how your conditional compiles work with the dev switches, and that took some time. But I still have some issues:
1. I can only read one card a 2GB ADATA . I bought 2 new cards today an 8GB ADATA HC and a LEXAR 16GB SDHC. Both of these cards work in the camera, but I can't read the "NIKON D3100 MISC" headers using scroll_LFN.bas as I should be able to. Also cant read an older card I have from the camera a 2GB SILICON POWER 45x card. Maybe I have some switches wrong?
2. I have cut & pasted your example_write_file.bas to the front end of your scroll.bas and once I sorted out the missing decl ( eg sddebug which doesnt seem to be declared anywhere) the prog compiles and runs BUT it takes over a minute to work its way throught the example_write_file.bas part of the code, and in the sub SDwritefsinfo:, the sdstatus is returned as 7, which is a timeout. I'm about to put some more debugging into this sub to see whats happening. Any pointers would be appreciated. I'll report back in an hour or so. Seems I cant leave this page open, without it timing out on me.
neil _________________ Neil |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Wed Jun 29, 2011 8:04 am Post subject: |
|
|
Added info:
status of the 10 output variables at the end of SDcreatefileordir are ( in the order you have listed them ) 0,0,1,2,1,1,0,1,0,0 and sdstatus at the end of sdfinalizeafterwriting and sdwritfsinfo is: sdstatus = 0 in both cases. But I cannot see any new file or directory either using the uP or using a PC SD card reader and I can read it OK) , so I assume a file isn't being created inspite of the sdstatus indicating to the contrary.
neil _________________ Neil |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Wed Jun 29, 2011 9:50 am Post subject: |
|
|
Hi Neil
Thanks for your swift replies. One thing I noticed when I developed the lib is that the implementations of the SD standard can vary quite much from manufacturer to manufacturer.
My first advice here is to start a new "debug project", and only do the SD initialization. You can set the developer switch Sdinitdetail to 0 for a verbose initialization, and insert statements that PRINT #1 Sdstatus and certain other variables' contents.
The next thing to check is if you should adjust your SPI speed depending on your clock frequency.
Then I would like you to check that you have pull up resistors on all the necessary pins.
Please start with this and let me know what you find.
Kind regards
Niclas |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Wed Jun 29, 2011 10:10 am Post subject: |
|
|
Hello Nicolas,
I have 68k pullups to 3.2vDc on all pins except the ck, and also on the 2 unused pins. ( exactly as per ur dwg, except that the alias's had to be changed because the SPI pinouts were different on this processor). I have checked the hardware v carefully several times. Anyway, the connections must be correct else I wouldn't be able to do a read of the NIKON file names, which I can.
The processor I am using is a 328P running at 8mhz RC osc, and the fuse bit for the ck divide is off.
I have the SPI set to 64, but have tried 32. I will do as you suggest tomorrow and get back to u.
neil. _________________ Neil |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Wed Jun 29, 2011 7:43 pm Post subject: |
|
|
Hi Neil
Could you please let me know the manufacturer part number for the cards you are having problems with? Maybe I can buy one of them and try.
There's another thing you should know: If you just pull out the card from a Windows PC, Windows will keep its file system buffering. If you add a file to the SD card (e.g. with your AVR) and re-insert it into the PC, Windows will still be working with the old file system buffer. (This caused me many hours of bugtracking...). Please make sure that you eject the card from inside Windows (or restart the PC) before you insert the SD card again.
I looked up your camera on the internet and found out that it supports both SDSC/SDHC and SDXC. This means it could have support for both FAT16/32 AND exFAT - in other words two quite different file systems (FAT16 and FAT32 are quite similar, while it is assumed that exFAT is not). As a designer, I would try to implement only one file system, which in this case would probably be exFAT. Ergo, I wonder if you camera might format all cards with exFAT. Could you please try and format one of the cards in a Windows PC and try it with your AVR?
Kind regards
Niclas |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Thu Jun 30, 2011 1:16 am Post subject: |
|
|
Hello Niclas,
success. !! I'll report back later with detail.
neil _________________ Neil |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Thu Jun 30, 2011 9:23 am Post subject: |
|
|
Niclas,
Well it was thanks to you that I found the problem. I ran SDinit ( verbose compile ) alone, and found that the sw got into a continuous loop, where it stayed for 30 seconds at a time. The loop was sdresponseloop. The fact that I could read the file names lead me ( wrongly it turned out) to believe the hardware was OK, but your prompt caused me to look at it again. Problem was my quick and dirty conversion from 5v to 3.3, which was allowing the 3.3v to rise & fall slightly with the cs pin. When i put a stiffer 3.3 v supply on the card the processor, suddenly I could read & write to all the sd cards I was using.
A question Niclas- Why do u write to MSB first, which is at odds with normal bascom order?
neil _________________ Neil |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Fri Jul 01, 2011 9:56 am Post subject: |
|
|
Hi Neil
I'm happy to hear that you found the problem.
PSU problems are tricky, partly because you tend to forget that it exists. This actually reminds me of a similar problem you might experience when developing-testing-developing: If you are using a uC with only one SPI interface, it is probably shared between the SD card and the ISP programmer. In order to avoid problems, make sure that you always disconnect the programmer after programming. In my case, the programmer interfered, sometimes resetting the uC.
Regarding the MSB question: I'm not sure that I understand. SD cards want the data MSB first. Similarly, FAT16/32 store data on the card in a certain order (little endian, meaning byte 0 is stored first and byte x is stored last). BASCOM basic is designed to be as similiar to Visual Basic as possible, which (in the case of arrays) is not a blessing: When addressing the card, you must often consider the offset by 1. (VB arrays start at 1, while the numeric system starts at 0.)
Anyway: congratulations on your success. Please let me know if you run into further issues.
Kind regards
Niclas |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|