I am currently trying to get Sparkfun’s USB Bootloader code working on a Olimex LPC2148 board. I have successfully gotten the bootloader onto the arm device however the removable drive does not show any files. I believe this is due to the declarations of MOSI, SCK, and MISO. They are currently configured for SPI0 rather than SPI1.
I believe I changed everything necessary to change over to SPI1. Can anyone who has attempted this or has more experience with ARM SPI verify the following changes?
Thats not enough.You must also re-write functions for void sd_raw_send_byte(unsigned char b) and unsigned char sd_raw_rec_byte(void).Oh and dont forget to change select_card() and unselect_card().
/* initialize SPI with lowest frequency; max. 400kHz during identification mode of card */
//S0SPCCR = 150; /* Set frequency to 400kHz */
//S0SPCR = 0x38;
SSPCPSR = 150;
SSPCR0 = 0xC7;
...
/* switch to highest SPI frequency possible */
//S0SPCCR = 60; /* ~1MHz-- potentially can be faster */
SSPCPSR = 60;
I also made changes to the two other functions that modify the SPI registers. As the SSPSR doesn’t generate an interrupt, I am checking if the Transmit FIFO is Empty.
void sd_raw_send_byte(unsigned char b)
{
SSPDR = b;
/* wait for byte to be shifted out */
while(!(SSPSR & 0x01));
}
unsigned char sd_raw_rec_byte(void)
{
/* send dummy data for receiving some */
SSPDR = 0xff;
while(!(SSPSR & 0x01));
return SSPDR;
}
I believe select_card() and unselect_card() are modified when defining SS_PORT_1. Please correct me if I am wrong.
Made the following changing in lpc2000_spi.c which does initial initialization of the SPI hardware. Seems a little redundant with sd_raw.c doing the same. Now the device shows up as “USB Device Not Recognized”. I’ll keep hacking it.
Erased the flash and rewrote the main.hex image and now the device shows up but still does not show file contents. I believe I changed everything necessary.
I never got the SPI1 working with the SD card. However, the code that I posted does show up as an external hard drive. However, when I click on the hard drive nothing shows up. What are you receiving as an output on UART0? I received an “0xFF Unrecognized Device” error but everything else booted correctly. Try double checking your hardware and if it is custom try verifying it with the Olimex LPC2148 schematic.
Just to verify the everything worked on the OLIMEX LPC-P2148, I jumpered SPI0 signals to SPI1 signals which connect to the SD card. Since the SPI1 pins are hi-Z I did not have to cut any connections
SSEL0–>SSEL1
SCK0–>SCK1
MOSI0–>MOSI1
MISO0–>MOSI1
Plugged in the USB cable, drive showed up immediately. I was able to copy files back and forth.
The Bootloader does not work. The bootloader tries to open rootdir and seems to get stuck in an ininite loop
kmeagher:
Just to verify the everything worked on the OLIMEX LPC-P2148, I jumpered SPI0 signals to SPI1 signals which connect to the SD card. Since the SPI1 pins are hi-Z I did not have to cut any connections
SSEL0–>SSEL1
SCK0–>SCK1
MOSI0–>MOSI1
MISO0–>MOSI1
Plugged in the USB cable, drive showed up immediately. I was able to copy files back and forth.
The Bootloader does not work. The bootloader tries to open rootdir and seems to get stuck in an ininite loop
Hi, Would you be interested in posting your SSP SPI1 register settings and related code to init, read and write SPI1??
Thanks i’m sure that it will help me greatly; so far havent had any success getting the SSP SP1 working with either the LIS3 accelerometer or a NOKIA 6610 LCD. Neil