Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Blueteeth said:...the 'CS' line is only used for single byte transfers.
Papabravo said:I know you know how to make SPI periperals do their thing...
So what does mean? This was the part that confused me.
void spi_write(unsigned char txdata1, unsigned char txdata2)
{
unsigned char rxdata, rxdata1, rxdata2;
CS = 0; //chip select
rxdata1 = SSPBUF; //lose data in buffer
SSPBUF = txdata1; //write the first MAX3100 control byte
//0b10000000
while(!STAT_BF); //loop until buffer contains data
rxdata1 = SSPBUF; //retrieve data
SSPBUF = txdata2; //write the second MAX3100 data byte
while(!STAT_BF); //loop until buffer contains data
rxdata2 = SSPBUF; //retrieve data
CS = 1; //de-select chip
}
void spi_puts(const char *str)
{
while(*str){
//putch(*str);
spi_write(0b10000000, *str);
str++;
}
}
rxdata1 = SSPBUF; //clear BF
do{
SSPCON_WCOL=0; //clear WCOL
SSPBUF=txdata1; // write data
}while(SSPCON_WCOL); // if collision do it again
while(!STAT_BF); // wait for transfer to finish
rxdata1 = SSPBUF; // clear BF for next transfer
do{ // do next byte
void spi_init()
{
STAT_CKE = 1;
spi_write(0b11000100, 0b00001011);
while(spi_ready(0b01000000, 0b00000000));
}