I am having a really tough time getting any data out on my SPI port. Using this:
#class auto
#define SPI_SER_B
#define SPI_CLK_DIVISOR 500
#use spi.lib
void main()
{
char reading[2];
char sending[2];
sending[0] = 0x0F;
sending[1] = 0xF0;
SPIinit();
while(1)
{
SPIWrRd(sending, reading, 2);
printf(" Sending 0x%x 0x%x
Reading 0x%x 0x%x
", sending[0], sending[1], reading[0], reading[1]);
}
}
This is just a simple test. I am using the RCM4010 on the dev board right now. I can see my clock on portb.0, I can read data fine on portc.5, but on portc.4 I can not get anything to move, it just sits at ground. Any ideas? Thanks.
Turns out the SPI.LIB doesnt setup the Port C Function Register (PCFR), or it did it incorrectly. When I read it I got a value of 0xC0, showing pins C6 and C7 (used to communicate with computer) were setup for special functions, when serial channel B SPI uses C4 and C5. As to why I could still read my SPI through C5 and not write to C4 I have no idea. It comes out to:
#class auto
#define SPI_SER_B
#define SPI_CLK_DIVISOR 500
#use spi.lib
void main()
{
char reading[2];
char sending[2];
sending[0] = 0x0F;
sending[1] = 0xF0;
SPIinit();
BitWrPortI(PCFR, &PCFRShadow, 1, 4);
BitWrPortI(PCFR, &PCFRShadow, 1, 5);
sending[0] = 0x55;
sending[1] = 0x0F;
while(1)
{
SPIWrite(sending, 2);
SPIRead(reading, 2);
printf(" Sending 0x%x 0x%x
Reading 0x%x 0x%x
", sending[0], sending[1], reading[0], reading[1]);
}
}
Just wrote to two bits after the SPIinit().