Please help me.
Develop a circuit with the PIC18F452 which reads a SD / MMC.
The problem is that I'm trying to do this same circuit to work with the PIC18F2550 and I can not access the SD Card / MMC.
Someone could post a fully functional code to access and read a SD / MMC card using a PIC18F2550 and which pins should be used?
Thanks to all.
Por favor me ajudem.
Desenvolvi um circuito com o PIC18F452 que faz leitura num Cartao SD/MMC.
O problema é que estou tentando fazer este mesmo circuito funcionar com o PIC18F2550 e não estou conseguindo acessar o Cartao SD/MMC.
Alguem poderia postar um código totalmente funcional para acesso e leitura de um cartao SD/MMC usando um PIC18F2550 e quais pinos deverao ser usados?
Muito Obrigado a todos.
18F2550 SD/MMC
Moderators: David Barker, Jerry Messina
Hello dear friend! Thank you for your attention.bitfogav wrote:So have you got it working with a 18F452?.
Could you post your code for the 18F2550 and maybe we could work with that, to see where the problem is?.
I was using the following code.
Code: Select all
Device = 18F2550
Clock = 48
Config PLLDIV = 1, CPUDIV = OSC3_PLL4, USBDIV = 2, FOSC = HSPLL_HS, VREGEN = ON
#option SD_SPI = MSSP
#option SD_SUPPORT_SUB_DIRECTORIES = True
Include "SDFileSystem.bas"
// MAIN PROGRAM
Repeat
Until SD.Init(SpiOscDiv4)
SD_CS TO PORTC.2
SD_CLK TO PORTB.1
SD_DO TO PORTB.0
SD_DI TO PORTC.7
I do not understand why not working
I changed the code and get access to sd / mmc.
CODE
Code: Select all
Device = 18F2550
Clock = 48
Config PLLDIV = 1, CPUDIV = OSC3_PLL4, USBDIV = 2, FOSC = HSPLL_HS, VREGEN = ON
#option SD_SPI = SW
#option SD_SUPPORT_SUB_DIRECTORIES = True
#option SD_CS = PORTC.2
#option SD_CLK = PORTB.1
#option SD_DO = PORTB.0
#option SD_DI = PORTC.7
Include "SDFileSystem.bas"
// MAIN PROGRAM
Repeat
Until SD.Init()
You need to make sure that your circuit is something like this below (follow link below), dont forget the pull-up resistor 10k on the SD DO pin but you really should use a 3V3 -> 5V level shifter..
make sure the pins are setup like this:
SD_CS = PORTC.2
SD_DI = PORTC.7
SD_CLK = PORTB.1
SD_DO = PORTB.0
circuit diagram here SDCardCircuit
Here is an example code ive put together for the 18F2550, but im using a 20Mhz external crystal.. The code below will first Format the SD card and then make a New File and write lines 0 to 255, I hope this helps get you started
make sure the pins are setup like this:
SD_CS = PORTC.2
SD_DI = PORTC.7
SD_CLK = PORTB.1
SD_DO = PORTB.0
circuit diagram here SDCardCircuit
Here is an example code ive put together for the 18F2550, but im using a 20Mhz external crystal.. The code below will first Format the SD card and then make a New File and write lines 0 to 255, I hope this helps get you started
Code: Select all
// device and clock...
Device = 18F2550
Clock = 20
// setup values for PIC 18F2550
#option SD_CS = PORTC.2
#option SD_DI = PORTC.7
#option SD_CLK = PORTB.1
#option SD_DO = PORTB.0
#option SD_SPI = MSSP
#option SD_SPI_SPEED = spiOscDiv4
#option SD_SUPPORT_MULTIPLE_FILES = false
// import modules...
Include "SDFileSystem.bas"
Include "Convert.bas"
// variables...
Dim Index As Byte
// disable comparator inputs
CMCON = %00000111
// adc - VDD/VSS ref, ALL pins Digital pins
ADCON1 = %00001111
// delay to let power settle
DelayMS(1000)
// program start...
If SD.Init() = errOK Then
// format SD card...
QuickFormat
// write data to SD card...
If SD.NewFile("test.txt") = errOK Then
For Index = 0 To 255
SD.Write("Line ",DecToStr(Index,3), 13, 10)
Next
SD.CloseFile
EndIf
EndIf
Just to make it more clear, here is the modified circuit I put together for the PIC 18F2550
http://digital-diy.com/forum/download/file.php?id=1890
http://digital-diy.com/forum/download/file.php?id=1890
Thank you my friend.bitfogav wrote:Just to make it more clear, here is the modified circuit I put together for the PIC 18F2550
http://digital-diy.com/forum/download/file.php?id=1890