I m working with this RCM4500 and using this SPI function but it didint seen to work. i read some of the post and notice that the comment was to us Serial B instead of serial C. but i have already use Serial B for my xbee.
Was serial C not competible for SPI? i used and edited they sample coding given:
#define SPI_CLK_DIVISOR 100
SPIWrite("\x05", 1); \\ cmd to write to register
printf("SPI bytes = 0x%x 0x%x
", adc_reading, adc_reading);
I always got a 0xff or 0x00
Or is my pin configuration wrong? Below is my configuration:
PC3 connected to Dout of my SPI component
PC2 connected to Din of my SPI component
PD2 connected to SCLK of my SPI component
What about chip select? I’ve got some devices here that will not work if you just ground /CS…
Haven’t used SPI.LIB myself - I just roll my own - so I can’t speak to that aspect of it. I do use serial port C as an SPI port though (this is on an RCM 5700, not 4500), so there should be no problem there.
Another thing to look at: You haven’t shown your port initialization. Have you set up Serial Port C to map to the pins you are using?
Whyd you need to throw in the part about telling Mike you wouldnt post about this then turn around and did just that?
Ive not had any problems.
Thanks for your quite respond. Initalising? To do u mean this?
#define SPI_DR SCDR
#define SPI_CR SCCR
#define SPI_ShCR SCCRShadow
#define SPI_SR SCSR
#define SPI_ER SCER
#define SPI_ShER SCERShadow
WrPortI ( SCDHR, NULL, (SPIdivisor>>8) | 0x80 );
WrPortI ( SCDLR, NULL, SPIdivisor & 0xFF );
its defined in the spi library.
Ok i will connect tthe chipselect and see if it works.
By initializing, I’m referring to setting up the parallel ports. Like this, which won’t be exactly what you need to do, but should give you the idea:
// Parallel Port C Setup
WrPortI(PCDDR, &PCDDRShadow, (PCDDRShadow & 0xF3) | 0x0C); // PC2 & 3 are outputs
WrPortI(PCALR, &PCALRShadow, (PCALRShadow & 0xCF) | 0x00); // PC2: Alt out 0 (TxC)
WrPortI(PCFR, &PCFRShadow, (PCFRShadow & 0xF3) | 0x04); // PC2 alt out, PC3 norm
// Parallel Port D Setup
WrPortI(PDDDR, &PDDDRShadow, (PDDDRShadow & 0xF3) | 0x0C); // PD2, 3 are outputs
WrPortI(PDALR, &PDALRShadow, (PDALRShadow & 0xCF) | 0x00); // PD2: Alt out 0 (SCLKC)
WrPortI(PDFR, &PDFRShadow, (PDFRShadow & 0xF3) | 0x04); // PD2 alt out, PD3 norm
The registers are described in the Microprocessor User’s Manual for whatever processor you are using.
Hi, im also trying out the spi in rabbit, im trying to connect it with a adc, so basically what pins do i need to wired out to the rabbits port…
Vcc to +3.3V
Gnd to Gnd
SCLK to SCLKA
Chip Selection to Any Output Port
Data out to TxB
Data In to RxB
is it something like this?