Yes, the 2550 and 4550 will run on 3.3 volt. See the link in post #4.
Use a 4MHz external OSC and the chip can be PLL'ed to 48 MHz if needed. The electrical section of the data sheet shows what can be done.
Dave
Always wear safety glasses while programming.
I've been playing with this code for a couple days now with no joy. My biggest question revolves around my SD card. I have several. They ALL have 9 pins. As does the socket on my development board. Yet the code seems to be written for an SD card with 12 pins? I have no "Write Protect" or "card detect" lines, nor can I find reference to them anywhere but on this site. Do I fake the pins? High or low?
To further add to the confusion, I'm using an 18F2550 and I need the hardware serial port. Since a pin is shared with the hardware SPI port, I'm trying to use SHIFTOUT / SHIFTIN. Things seem to be getting to the SD card, but it does not reply (I get 0's).
Am I missing something simple? Response from an INIT is 6...
Hi Charlie,
I use PIC18F25K22
and do it this way:
'--------------SD CARD----------------------
'SD_DO VAR PORTC.0
' Alias PIC pins and registers for SD/MMC cardYTE
SDI VAR PORTC.0 ' SPI data in SD #7 (SD_DO)
SDI_TRIS VAR TRISC.0 ' SPI data in direction
SCL VAR PORTC.1 ' SPI clock SD #5
SCL_TRIS VAR TRISC.1 ' SPI clock direction
SDO VAR PORTC.2 ' SPI data out uSD #3
SDO_TRIS VAR TRISC.2 ' SPI data out direction
SD_CS VAR PORTC.3 ' SD card chip select uSD #2
SD_CS_TRIS VAR TRISC.3 ' SD card chip select direction
'SD_CD VAR bit: SD_CD = 1 PORTC.0 ' SD card detect
'SD_CD_TRIS VAR TRISC.0 ' SD card detect direction
INCLUDE "SDFS.PBP"
SDC_UseHardSPI = FALSE ' Use hardware SSP port for SPI.
...
all lines in the SDFS.PBP that refer to the card write protection, card inserted and so on things I disabled like this:
' Subroutines for communicating with an SD/MMC card
' Subroutine to initialize SD card pins
InitIO:
SD_CS = 1 ' SD card not selected.
SD_CS_TRIS = 0 ' Output SD card chip select.
''' SD_CD_TRIS = 1 ' Input card detect.
''' SD_WE_TRIS = 1 ' Input write protect.
SDO = 1 ' Start SPI data out high.
SDO_TRIS = 0 ' Output SPI data out.
SDI_TRIS = 1 ' Input SPI data in.
SCL = 1 ' SPI clock idles high.
SCL_TRIS = 0 ' Output SPI clock.
Return
' Subroutine to initialize hardware SSP for SPI at less than 400kHz
OpenSPIM:
If (SDC_UseHardSPI) Then
''' SSPSTAT = 000000 ' Sample at middle of data output time, Mode 1, 1: Transmit on idle to active clock transition.
''' SSPCON1 = 010010 ' SPI master mode, clock = Fosc/64, Mode 1, 1: Clock idle high.
''' SSPEN = 1 ' Enable hardware SPI port.
Endif
Return
' Subroutine to initialize hardware SSP for SPI at full speed
OpenSPIMFast:
If (SDC_UseHardSPI) Then
''' SSPSTAT = 000000 ' Sample at middle of data output time, Mode 1, 1: Transmit on idle to active clock transition.
''' SSPCON1 = 010000 ' SPI master mode, clock = Fosc/64, Mode 1, 1: Clock idle high.
''' SSPEN = 1 ' Enable hardware SPI port.
Endif
Return
I use micro SD card. You might notice the pins used for card interface are shared with ICSP, but the card can not work while the programmer is connected. Programmer probably does not like such neighbor too (one needs pull up and the other has internal pull down, but it works.
I could not attach the file - error happens - "invalid file" I do not know why, but you see the idea - just comment everything you do not use
Best regards,
Thanks, Alexey.
I had done something similar, but tried your solution anyway. Still not working. It's possible my SD card is simply not happy with this initialization sequence - I can see clock and "data in" pins (Pic "data out") moving as they should (as best as I can judge with LED's) but the device does not respond. If I put a pullup on it's "data out" line (PIC "data in") I can read FF, otherwise I read 00. To me this means the card is not driving the line.
I know I should post my code, but it's about 8K. After your post, I did try the SDFS3.PBP program with tweaks for my hardware specifics and it did not run either. I might have to go back to a 24L series device...
Hi Charlie,
You need to have pull-ups on both, data and clock lines
Just FYI, I finally resolved the issue... turns out my development board has a schematic error. I guess I should have bought the expensive one. Wait... considering it just cost me several days of my life - looks like I did.
Bookmarks