Hi E
That's more or less what I'm doing with the direct addrssing. I didn't try the method you show in the .bas file, but that looks promising. Set CS but don't use it.
The PIC is the master and the BME and Max7219 are both slaves.
Before I try anything else though, I have a hardware problem. When I connected up SDI, SDO and SCK to the BME280 (Max 7219 was already connected) , the 5V went down.
I tried a few variations, and found that SCK was causing the problem. I think that's what killed the BME280.
The BME worked fine on its own, I was able to set up and receive data from the BME. I even got Temp, Pressure and Humidity readings using Oshonsoft AVR IDE.
I switched to PIC16F877a after my Mega328P failed (bad connection on the Xtal).
The max7219 also worked with 877a. it was only when the SCK was joined up to all 3 devices that the 5v failed. Joining SPI/SPO made no difference.
I checked the 3.3v-5v level changer this morning and that is working as it should, so definitely a dead BME280.
The only difference I can see between BME and Max is that the clock (SCK) is idle low for one and idle high for the other.
I can't see why that should destroy the chip though.
I think I'll buy a 5v version of the BME280, i.e. one with built in level changer, at least that takes one bit of the circuit out of the equation.
Oh yes why did I consider using Interrupts .....because you said so!!! Although polling isn't as efficient, the PIC hasn't got much else to do in this program, so it probably doesn't make too much difference. I think I'll persue the Interrupt method because it's something I want to understand better.
The Max7219 is pretty dumb, data in only, data out of its shift registers at SDO to another max7219 if needed.
The BME is a slave too but it does have a lot of configuration registers, most of which can be read. The favouite is chip id, sending to register 0x0D (no data needed), will get a return byte of 0x60, its id. So even if nothing else is setup, the chip id will show a sign of life.
Anyway I have plenty to work with now, the main problem was the hardware, I wasn't getting any response from the BME280 because it was dead! Why is another matter.
I have a suspicion that the program will work fine with a functioning BME280.
The best made plans of mice and men!!!