Hi J,I mean was compass CS off, when reading bmp280?
In #24 the xlsb has ok values for temperature and pressure and change between measurements which is normal.Hi J,
In #24 the commented out sections, plus many more were tested, and there are so many combinations.
again, I've tried switching CS ON/OFF in many tests. From memory, in the working program they weren't switched ON/OFF between READs.
I've had a suspicion that XLSB and LB are the wrong way round. At the moment they are the same as the OSH working program.
C.
Hi J,In #24 the xlsb has ok values for temperature and pressure and change between measurements which is normal.
What has been changed after it?
#37 looks like it is not measuring at all.
Hi J,I have not seen periph_rd_alt function.
Function rd_nxt_reg() As Byte
WaitUs 1
SSPBUF = 0
While Not SSPSTAT.BF
Wend
rd_nxt_reg = SSPBUF
End Function
'-------------------------------SPI FUNCTIONS-------------------------------------------------
Function periph_wr(wr_adr As Byte, wr_data As Byte) As Byte
WaitUs 1 '/// maybe not needed
SSPBUF = wr_adr
While Not SSPSTAT.BF 'PIC
Wend
WaitUs 1
SSPBUF = wr_data
While Not SSPSTAT.BF 'PIC
Wend
End Function
Function periph_rd(rd_adr As Byte) As Byte
WaitUs 1
SSPBUF = rd_adr
While SSPSTAT.BF 'PIC
Wend
WaitUs 1
SSPBUF = 0 'Dummy BYTE
While Not SSPSTAT.BF 'PIC
Wend
periph_rd = SSPBUF
'While drdy_pin 'ADDED??????????????????????????
'Wend
End Function
'############################################'******ADDED**************?????????
Function periph_rd_alt(rd_adr As Byte) As Byte
'WaitUs 1
SSPBUF = rd_adr
While Not SSPSTAT.BF 'PIC
Wend
'WaitUs 1'Below
While STATUS.3 'Must have this or WAIT
Wend
SSPBUF = 0 'Dummy BYTE
While Not SSPSTAT.BF 'PIC
Wend
periph_rd_alt = SSPBUF
End Function
'#######################################

Hi B,This sounds like the OSCCON register is not being initialized in your code. This has bit me a few times on other processors where now I make it a habit to force the oscillator to run the way I want it to.
Here is what happens: When you program the device "NEW" everything works as you expect. If you are powering from the PicKit3 or some other programmers, and you reset the micro. The micro 'sees' this as a conditional reset that puts it into a default clock mode of 1MHz.
See page #28 and #33 of the datasheet... (Note #3)
Reference: https://ww1.microchip.com/downloads/en/DeviceDoc/40001303H.pdf
View attachment 249345
External crystal or not, a Power ON reset will put the micro in a low power 'safe mode' of 1MHz ... See OSCCON on page #57 Table 4-4 of the PDF.Hi B,
This has caught me out as well, so I changed to Crystal oscillator, and I'm pretty sure no need for OSCCON.
Thanks,
C.
Hi B,External crystal or not, a Power ON reset will put the micro in a low power 'safe mode' of 1MHz ... See OSCCON on page #57 Table 4-4 of the PDF.
All you need to do is force OSCCON to the value you want at the beginning of your program in your initialization section.
Hi E,I searched a little bit and found that you had 2 years ago a program using SSPBUF with sensible results.
https://forum.allaboutcircuits.com/...0-and-bmp280-in-oshonsoft.162449/post-1427699
Maybe you should check the SSPSTAT, SSPCONFIG1 and BMP280 setup from that program ( msg #100 in that thread )
Hi B,External crystal or not, a Power ON reset will put the micro in a low power 'safe mode' of 1MHz ... See OSCCON on page #57 Table 4-4 of the PDF.
All you need to do is force OSCCON to the value you want at the beginning of your program in your initialization section.
What does this mean: SSPCONFIG1 L=same H=0x02 ?Hi E,
I found the program. I've changed a lot of things since then (a bit tidier) also the PCB has changed, so quite a big job to get it onto this PCB.
I checked SSPSTAT CKE=1 CKP=0 the opposite of today. Today's settings match the D/S.
SSPCONFIG1 L=same H=0x02 Today H=0x06 Crystal +PLL = 32MHz
DEFINE Clock frequency = 8 Today =32
Did I miss anything?
C.
Or maybe you mean CONFIG.L CONFIG.H ?What does this mean: SSPCONFIG1 L=same H=0x02 ?
"Settings match the D/S" which D/S ?
Hi J,I sShould have been clearer!What does this mean: SSPCONFIG1 L=same H=0x02 ?
"Settings match the D/S" which D/S ?
Hi E,