View previous topic :: View next topic |
Author |
Message |
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Sun Feb 26, 2006 1:41 pm Post subject: Newbie with AVR-Dos to SD Card begging for help |
|
|
I'm trying to use an ATMega 128L to datalog temperature data to an SD Card.
Keep it simple I thought ; just write a very simple proge to output data to a SD Card. Make it better / tune it to my particular requirements later I thought ... So I've read just about every forum note I can and just confuse myself further...
I've posted the code below. Most of it is cobbled together from various sources but is does make sense to me... maybe one of you has the time to give me some advice... Thanks chaps...
================ MY CODE =================
'-------------------------------------------------------------------------------
' SPI.BAS
' homemade SPI example - attempts to teach SPI basics and then progress onto
' full SD Card file storage and retrieval...
'-------------------------------------------------------------------------------
'System DEFAULT Setup
$RegFile = "m128def.dat"
$Crystal = 9830400
$Framesize = 256
$HWStack = 64
$SWStack = 512
' Bascom Full version 11.7.7
' STK300 Dev Board
' ATMega 128L operating at 3.3V
' 9.8304MHz Xtal
Dim ss as Byte , strTxt as String * 32 , bytInitFS as Byte
'500mS Clock Pulse Interrupt
Config Timer1 = Timer , Prescale = 64
Const Timer1Reset = &HB500 'Set to provide a clock pulse @ 500 mS intervals (&HB500@9.830400MHz)
On Timer1 Timer1_Reset
Config Clock = Soft
Time$ = "00:00:00"
Date$ = "01/01/01"
'Dims _Sec as Byte, _Min as Byte, _Hour as Byte, _Day as Byte, _Month as Byte, _Year as Byte for FAT/AVR-DOS file data)
'Hardware UART(0) - PE0/1
$Baud = 19200
Config SerialIn = Buffered , Size = 128
Config Com1 = GPS , Synchrone = 0 , Parity = None , StopBits = 1 , DataBits = 8 , Clockpol = 0
'Hardware UART(1) - PD2/3
$Baud1 = 19200
Config SerialIn1 = Buffered , Size = 128
Config Com2 = ETNetwork , Synchrone = 0 , Parity = None , StopBits = 1 , DataBits = 8 , Clockpol = 0
Open "com2:" For Random As #1
'Show that we're starting
Print #1 , "Start" : Waitms 100
'Hearbeat (Pulsing LED just to let us know something's going on...)
Config PortB.7 = Output
Heartbeat Alias PortB.7
Reset Heartbeat 'Just to let us know we've got this far
'Push to End/Exit switch
Config PortD.7 = Input
$Include "Config_MMC.bas"
If gbDriveError <> 0 then
Print #1 , "Card Error " ; gbDriveError
Waitms 100
' Insert Call to Card Error Handler sub here !
End
End IF
$Include "Config_AVR-DOS.bas"
bytInitFS = InitFileSystem(1)
If bytInitFS <> 0 then
Print "File System Error " ; bytInitFS
Waitms 100
' Insert Call to DOS Error Handler sub here !
End If
Open "Test.txt" For Append As #10 'Filenums >=10 are best
Do
'Do this code / write to the 'Test" file once per second
If ss <> _Sec Then
ss = _Sec
strTxt = Date$ + " " + Time$
'O/p data to the Test file...
Print #10 , strTxt
'... and now to a HyperTerminal (or similar) screen...
Print #1 , strTxt
'Check to see if you want to exit now...
If PinD.7 = 1 Then Goto EndProg
End If
Loop
'Heartbeat LED
Timer1_Reset:
Toggle Heartbeat
Return
'End our little Test Prog here
EndProg:
Close #10
Print #1 , "End of Prog..."
Close #1 'Unnecessary I think but tidy...
Waitms 100
End
===============END OF CODE ===============
When I attempt to compile I get multiple errors caused by the OPEN...#10, PRINT #10 and Close #10 lines. Remm'ed out all's OK (but obviously the prog doesn't function SD-wise...)
Error : 31 Line 108 : Invalid datatype [ 0] , in File : ......
Error : 203 Line 108 : Error in LD or LDD statement [Z+CO_FATCLUSTER] , in File : ...
Error : 203 Line 108 : Error in LD or LDD statement [Z+CO_FATCLUSTER_2] , in File : ...
Error : 204 Line 108 : Error in ST or STD statement [Z+CO_FATCLUSTER] , in File : ...
Error : 204 Line 108 : Error in ST or STD statement [Z+CO_FATCLUSTER_2] , in File : ...
Error : 203 Line 108 : Error in LD or LDD statement [Z+CO_FILEROOTENTRY] , in File : ...
Error : 203 Line 108 : Error in ST or STD statement [Z+CO_FILEROOTENTRY_2] , in File : ...
...
...
...
Error : 222 Line : 108 Illegal character [expected (, got"] ,in File : .....
I have no idea what I'm doing wrong.. I thought/ think I've pieced together all the right pieces but... obviously not...
Any help would be appreciated. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Sun Feb 26, 2006 11:48 pm Post subject: |
|
|
Being a Sunday I just couldn't leave this alone...
[1] My full version of BasCom is 1.11.7.7 - don't know if this makes any difference to AVR-DOS or if / how I can obtain an update - it's about 9 months old.
[2] Minor item but I omitted a Timer1 = Timer1Reset in my Timer1_Reset sub. Rectified - no changes here but...
[3] Downloading the latest versions of AVR-DOS and MMC.bas .LIB and .LBX files and playing about with their locations has helped - only one error now :
Error : 321 Line : 111 [undefined function 'Varexist'] ,in file....
(Line 111 = End, in my code)
The way to get here was, I think, to
(i) download the latest files as per [3] above
(ii) place Config_AVR-DOS.bas and Config_MMC.bas into my program/test file/code folder (referred to as "in file..." above )
(iii) place AVR-DOS.LBX and MMC.LBX in the Bascom root directory (C:/Program Files/MCS Electronics/Bascom/LIB)
(iiii) recompile...
However, I'm still left with the :
Error : 321 Line : 111 [undefined function 'Varexist'] ,in file...
Any ideas? Chaps, I'm not expecting anyone to fix this or write my code for me but if one of you could point me in the right direction whilst explaining (or telling me where to find out about .LIB, .LBX, .BAS files and their placement and purpose) I would be, as they say, forever in your debt... It would apear I'm out of my depth with this thing and I'm pretty desperate for some guidance...
Thanks. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
Posted: Mon Feb 27, 2006 3:58 pm Post subject: |
|
|
I assume, the first problem was an old CONFIG_AVR-DOS.BAS file.
You need for the last version the BASCOM-AVR release 1.11.8.1 or higher. _________________ regards Josef
DOS - File System for BASCOM-AVR on http://members.aon.at/voegel |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Mon Feb 27, 2006 5:29 pm Post subject: |
|
|
Good afternoon Josef,
Thanks for replying.
I don't know what the problem was; old version, wrong placement... I have no idea
Do you know how I can get a new/updated BASCom? I can't find anywhere to get an upgrade / revision from... well, not without purchasing the kit all over again...
Do you know of a sticky or similar for my .LIB, .LBX, .BAS request ?
ANY info. would help me at this stage...
Thanks again. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Mon Feb 27, 2006 5:36 pm Post subject: |
|
|
Hi,
To get a new Bascom go to the MCS site and click in the left panel on product registration en follow all the steps.
Frank. |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Mon Feb 27, 2006 5:51 pm Post subject: |
|
|
Thankyou Frankeman...
I know this is all very simple to those of you who are used to it - I'm afraid I'm not.
I did, however, do as you suggested and find my way to RE-Registering. Anyway, I'm now awaiting confirmation/approval and see where that will get me. I'm hoping that with the latest version of BasCom my code (above) will function.
Many thanks... I just thought that I had already registered ... _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Thu Mar 02, 2006 10:31 pm Post subject: |
|
|
This is like pulling teeth...
After 'registering' (I'm sure I already did this once but...) and downloading the latest everything I'm still going nowhere fast...
Connecting up to my SD Card produces the error 255 !! Nothin I do fixes / changes this (this error takes 34 seconds to arrive and in the mean-time the code just seems to 'hang'...)
Searching (blindly) I find someone (I think you, Josef) in response to someones post re: their card type, states that he has no problems with SanDisk cards... Aha, I think... I check my card (a test item - I plan to use SanDisk mini SD's at 1GB capacity) and find it's a DaneElec. For the hell of it I swap it out with one of my final SanDisk units (after formatting it to FAT32) and gosh... my error 255 goes (instantly) and is replaced with an AVR-DOS file init error #17.
Now I spend time searching for this... and get nowhere...
On the up-side, my code runs as expected with the exception of saving any data to the SDCard... at least I can't read the data or any file when I (after flush and close) try to read it back in my PC...
Please, Error #17 ? What does it mean ? ...and ...
where should I look to fix it ?... and ...
does someone have an error code listing (can I have a copy of it please) ?
That's it and thanks... as usual any info would be gratefully received...
In the meantime, I'll continue searching.. in case I missed something (probably...) _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Thu Mar 02, 2006 10:42 pm Post subject: |
|
|
Good evening (again)
Searching worked... a bit...
Error #17 = No MBR (Mater Boot Record ?)
I should have looked within the Config_AVR-DOS file first - whoops...
Hmm. Now what ? I've placed a dummy folder and file on the SD Card from my PC. Note this is SD Card formatted FAT32 but I think I've enabled that in the Config_AVR-DOS file so this shouldn't be a problem... ? should it ???? I didn't appear to have a FAT16 option for the card anyway... Win Explorer gave me FAT32 or FAT options... I'll try re-formatting with (just) FAT selected...
In the meantime, any help ???... cheers chaps. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Thu Mar 02, 2006 10:47 pm Post subject: |
|
|
And again
Now I get a Card Init error #255 AND an AVR-DOS File Init Error #229...
I'll go back to the way I was (Card formatted for FAT32)... _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Thu Mar 02, 2006 10:51 pm Post subject: |
|
|
And yet again... no doubt (if you're not already bored of this newbies antics...) this'll be getting boring now...
Re-formatted as FAT32 and I go back back 2 posts to my Card Init as OK (#0) and AVR-DOS File Init as Error #17...
Phew... ideas... Thanks... _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
|
Back to top |
|
|
|