error compiling SD CARD PLAYER code

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
edsonstedile
Posts: 8
Joined: Thu Jan 03, 2013 11:42 am

error compiling SD CARD PLAYER code

Post by edsonstedile » Thu Jan 03, 2013 1:30 pm

When compiling the basic code for the PIC18F452 to play a SD CARD,
it is pointed out an error concerning the command SD.Init(spiOsciDiv4),
stating that a Boolean expression is expected and that the identifier
spiOscDiv4 was not identified.
Thnaks for any suggestion.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Thu Jan 03, 2013 2:56 pm

If you're using SD lib V4.1.4, check out the wiki page on the SD library... some changes have been made to the Init() call.
Note that the Init command for initialising the card has been changed slightly since Version 3.1.1 and this will necesitate a change to existing user code. The command now returns a byte, not a boolean. The return variable gives more information in case of a failure (see err codes in comments above command in module for details). Note also that when using the hardware MSSP SPI option using #option SD_SPI = MSSP, the SPI bus speed is no longer passed to the Init command as a parameter, but is set using an option, e.g. #option SD_SPI_SPEED = spiOscDiv4. As for all options, this must be placed before the Include "SDFileSystem.bas" statement in the user code

edsonstedile
Posts: 8
Joined: Thu Jan 03, 2013 11:42 am

SD Card Player code

Post by edsonstedile » Thu Jan 03, 2013 5:04 pm

Thanks for your reply.

I have included the command
#option SD_SPI_SPEED = spiOscDiv4
before the comand
Include "SDFileSystem.bas"

as you can see at the beginning of the code, as shown below.
The error pointed out still holds.

Device = 18F452
Clock = 32
Config OSC = HSPLL
#option SD_SPI = MSSP
#option SD_SPI_SPEED = spiOscDiv4
#option SD_SUPPORT_SUB_DIRECTORIES = True
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.2
#option LCD_EN = PORTB.3
#option LCD_INIT_DELAY = 300
Include "SDFileSystem.bas"
Include "LCD.bas"


Device = 18F452
Clock = 32
Config OSC = HSPLL
#option SD_SPI = MSSP
#option SD_SPI_SPEED = spiOscDiv4
#option SD_SUPPORT_SUB_DIRECTORIES = True
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.2
#option LCD_EN = PORTB.3
#option LCD_INIT_DELAY = 300
Include "SDFileSystem.bas"
Include "LCD.bas" command

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Post by bitfogav » Thu Jan 03, 2013 5:59 pm

We need abit more information? Can you confirm what version of the SDCard library you are using?

edsonstedile
Posts: 8
Joined: Thu Jan 03, 2013 11:42 am

SD Card Player code

Post by edsonstedile » Thu Jan 03, 2013 6:55 pm

Thanks for your interest to help me.
I'm using the version v4.1.4 and followed the instructions (in green) concerning the changes to the SdInit() command given on the page of
SdFilesystem v4.1.4.

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Post by bitfogav » Thu Jan 03, 2013 7:05 pm

Thanks for confirming the SD lib version, now that you have changed the code to:

Code: Select all

Device = 18F452 
Clock = 32 
Config OSC = HSPLL 
#option SD_SPI = MSSP 
#option SD_SPI_SPEED = spiOscDiv4 
#option SD_SUPPORT_SUB_DIRECTORIES = True 
#option LCD_DATA = PORTB.4 
#option LCD_RS = PORTB.2 
#option LCD_EN = PORTB.3 
#option LCD_INIT_DELAY = 300 
Include "SDFileSystem.bas" 
Include "LCD.bas"
What is the compiler error now with the changes to the code?, because the code above looks correct.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Thu Jan 03, 2013 7:33 pm

When compiling the basic code for the PIC18F452 to play a SD CARD,
it is pointed out an error concerning the command SD.Init(spiOsciDiv4)
Are you trying to compile the SDMMCWavPlayer code? If so, that code looks to be written for the older SD lib version.

Try changing

Code: Select all

LCD.Cls
LCD.WriteAt(1, 1, "PLEASE INSERT SD")
Repeat
Until SD.Init(spiOscDiv4)
to

Code: Select all

LCD.Cls
LCD.WriteAt(1, 1, "PLEASE INSERT SD")
Repeat
Until (SD.Init() = ErrOK)
I have no idea if any other changes would have to be made to get it to work, though

edsonstedile
Posts: 8
Joined: Thu Jan 03, 2013 11:42 am

SD Card Player code

Post by edsonstedile » Thu Jan 03, 2013 8:13 pm

I've made the changes suggested. Now it is ponted out the error

Program variable allocation exceeds Swordfish Special Edition (SE)
maximum.

Is the compiler as a freeware edition limited for this code, say, the code is
too large for this edition ?

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Post by bitfogav » Thu Jan 03, 2013 9:07 pm

Yes im afraid so?.
The SE version is limited to the amount of RAM available to the user. This is because no bank switching code is available in the SE version.

edsonstedile
Posts: 8
Joined: Thu Jan 03, 2013 11:42 am

SD Card Player

Post by edsonstedile » Fri Jan 04, 2013 10:22 am

Thanks for your reply.

Post Reply