SPI mode

I've just started experimenting with the BP1 and currently developing my understanding of the SPI interface and trying to connect a thermocouple module (readily available on ebay) which uses a MAX6675. I now believe it uses mode 1 but the BPI uses mode 0 communication so my question is can the mode that the BP1 uses be changed?

The PIC32 does not have a single register bit(s) that will control the 'mode' as this register can also supply audio and so is more complex than a normal SPI set up. I can't tell you what the set up is that would be needed for the particular mode you need however I will show an example of changing the output from 8 bit communication to 16 bit communication by witting to the registers directly. In this way you can determine what you need from the data sheet and then set the registers accordingly

The SPI hardware registers can be directly accessed, bit length mode is set in the control register, the register addresses are here:
http://www.bypic.co.uk/index.php/MX1_Full and the relevant SPI registers are:

Thank's. A quick check on the data sheet and I can see the clock edge (bit 8) and polarity (bit 6), so I think I just need to configure these to set the mode. I will take a look at the rookie code to make sure I've not missed anything else and post back how I get on.

So it was in part an assumption that the default mode the BP1 used was 0, yup that was wrong. The rookie code is clear and (long story short) I can see register (SPI1CON) is initialised in the spi_init(speed) function with 0x8120 which among other things sets mode 1 (bit6 bit8). The issue I had was more to do with the algorithm needed to get the 2 byte reads into a temperature value which I've now fixed.

You could consider adding a variable to (for example) spi_init(mode,speed) and set bit6 bit8 in SPI1CON accordingly, but this would just cause a compatibility issue. It may though help just to add some further information in the comments. e.g. SPI default mode 1, set bit6 bit8 to subsequently change this similar to your example for changing 8/16 bit mode.

Thanks for you good guidance, this is a great development platform & device.

If anyone is interested I now have two functions, one to initialise the hardware and another to return an integer value of the read temperature