SPI PIC 18F4620 and BMP280 (In Oshonsoft)

ericgibbs

Joined Jan 29, 2010
21,530
hi,
The Calibration register is from 0x88 thru 0xA1 [ inclusive] that is 26 data address values.
So the b(x) has to cover b(0) thru b(25),,, so the Dim is b(26)............... not b(24) , which is only b(0) to b(23).
E

Dim i As Byte 'Altimeter compass (GPS checking )
Dim b(24) As Byte 'Altimeter compass'This number must cover [ 0 to X ] ?
Dim data As Byte 'Altimeter compass
 

Thread Starter

camerart

Joined Feb 25, 2013
3,846
hi,
The Calibration register is from 0x88 thru 0xA1 [ inclusive] that is 26 data address values.
So the b(x) has to cover b(0) thru b(25),,, so the Dim is b(26)............... not b(24) , which is only b(0) to b(23).
E

Dim i As Byte 'Altimeter compass (GPS checking )
Dim b(24) As Byte 'Altimeter compass'This number must cover [ 0 to X ] ?
Dim data As Byte 'Altimeter compass
Hi E,
The [23 ] is back :)
Did you look at all of the RED lines in my last post? Apart from the DIM is everything alse correct?
C
 

ericgibbs

Joined Jan 29, 2010
21,530
hi C,
Looked thru your 280918 basic program.:eek:

Why are you making the debugging program so bloated.?
As I said before, focus on a simple way of proving the SPI write/read to the Config regs.

BTW: do you have a list of the data pre-loaded into the Config regs by the manufacturer.? if so please post a copy.

E
 

ericgibbs

Joined Jan 29, 2010
21,530
hi C,
Programmed a 4620 and a 2341[ to act as a [BMP].
Look thru these two progs, the Arrays are set for y(26).... ie y(0) thru y(25)
So the invalid data due to sending the address 0x88 will be in y(0), which you later ignore, use y(1) thru y(25) for the data.

Do you follow OK.?
E
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
That is the problem!
Dim b has to be changed to 25.
hi,
The Calibration register is from 0x88 thru 0xA1 [ inclusive] that is 26 data address values.
So the b(x) has to cover b(0) thru b(25),,, so the Dim is b(26)............... not b(24) , which is only b(0) to b(23).
E

Dim i As Byte 'Altimeter compass (GPS checking )
Dim b(24) As Byte 'Altimeter compass'This number must cover [ 0 to X ] ?
Dim data As Byte 'Altimeter compass
There are 24 calibration values, addresses from 0x88 to 0x9F. 0xA0 and 0xA1 are reserved and not used.
 

ericgibbs

Joined Jan 29, 2010
21,530
hi jjw,
I know that the last two Calib regs are reserved, I left them in the SPI Read procedure so that 'C' would understand the idea of a 'burst' read, he can always ignore those two stored values.

With the information he has now, he should be able to Read the BMP280 Calib regs.

I keep trying to get him to write debug code for one section of the BMP at a time, rather than loading the program with all the bells and whistles.

E

The last Basic program he posted 200918 has 1170 lines of code.!!
 

Thread Starter

camerart

Joined Feb 25, 2013
3,846
Hi E and J,
In #102 I reported that the [ 23 ] is back, but omitted to say that I did what you advised to achieve this.

A month or so ago, we got a shorter de-bug program to work ok, and I took it as de-bugged, it was only then that I added it into the main SWSPI program, where I started converting to HWSPI. It was only when it broke for the above reasons, that it was a problem. I think I can carry on now, and hopefully show the TEMP and PRESS in a Terminal.

Working like this is the only way I can. Do you recall that a year or so ago, I tried to use INCLUDES (Apart from FONT) and I got hopelessly confused when piecing it all together. ( like a jelly jigsaw :) ) Sorry!

Previously, I asked a few questions in #100, regarding some lines, and whether they are needed or not. One of the lines makes [ b(0 - b(25) ] and [ DIM b(26) ] Which is what it is at the moment, and working as it should.
C.
 

ericgibbs

Joined Jan 29, 2010
21,530
hi C,
Look at this clip from your code, in RED, this test routine, when compiled, is used a number of time in your program...
It can be replaced by the very much shorter code in BLUE, saving you a lot of flash memory space.
E

Update: Hold on this, Oshonsoft gives two different results.!!! will check further.

; 52: If dig_t2 > 32767 Then
MOVF 0x014,W
MOVWF BARGB2
MOVF 0x015,W
MOVWF BARGB1
MOVF 0x016,W
MOVWF BARGB0
MOVF 0x017,W
MOVWF BEXP
CLRF AARGB2
MOVLW 0xFE
MOVWF AARGB1
MOVLW 0x7F
MOVWF AARGB0
MOVLW 0x8D
MOVWF AEXP
RCALL TALTB32
ANDLW 0x01
BTFSC STATUS,Z
BRA L0005

; 53: psing = psing - 65536

58: If dig_t2.15 = 1 Then

BTFSS 0x015,7
BRA L0006

; 59: psing = psing - 65536
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,846
hi C,
Look at this clip from your code, in RED, this test routine, when compiled, is used a number of time in your program...
It can be replaced by the very much shorter code in BLUE, saving you a lot of flash memory space.
E

Update: Hold on this, Oshonsoft gives two different results.!!! will check further.

; 52: If dig_t2 > 32767 Then
MOVF 0x014,W
MOVWF BARGB2
MOVF 0x015,W
MOVWF BARGB1
MOVF 0x016,W
MOVWF BARGB0
MOVF 0x017,W
MOVWF BEXP
CLRF AARGB2
MOVLW 0xFE
MOVWF AARGB1
MOVLW 0x7F
MOVWF AARGB0
MOVLW 0x8D
MOVWF AEXP
RCALL TALTB32
ANDLW 0x01
BTFSC STATUS,Z
BRA L0005

; 53: psing = psing - 65536

58: If dig_t2.15 = 1 Then

BTFSS 0x015,7
BRA L0006

; 59: psing = psing - 65536
Hi E,
You may recall that I can't read ASM, but your findings seem interesting.

I've now got the 18F4620 to READ the 'Compensation parameters' WRITE then READ (verify) the BMP280 settings.
I'm now trying to get the Calculation to work, and getting the READ to see changing READings, but so far the calculation isn't working. Note there are 3x BYTEs MSB LSB and XLSB.
C.
 

ericgibbs

Joined Jan 29, 2010
21,530
hi,
I know there are 3 bytes, refer my earlier posts.
I have a set up that uses a 18F4620 and a 18F2341 as BMP equivalent, gives out the Press and Tempr values when requested by the Master.
I can load different values into the 2431 ''BMP'' registers in order to verify the transfer.
Post a clip of the non working calcs.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,846
hi,
I know there are 3 bytes, refer my earlier posts.
I have a set up that uses a 18F4620 and a 18F2341 as BMP equivalent, gives out the Press and Tempr values when requested by the Master.
I can load different values into the 2431 ''BMP'' registers in order to verify the transfer.
Post a clip of the non working calcs.
E
Hi E,
I know that you know, including the 'shift right' which you mentioned :)

As the formula in #100 appears to be working, this is what I'm using, although I didn't receive all the answers to my questions in #100. (It's been edited)

Previously in SWSPI I READ the TEMP and PRESS in 2x sections. Now I'm trying to READ in 1x section.

My confusion is the order that each BYTE is READ.

Here are the relevant sections of BMP280 CODE: (Note some parts are commented out)
-----------------------------------------------------------------------------------------------------

C
 

Attachments

Last edited by a moderator:

ericgibbs

Joined Jan 29, 2010
21,530
hi,
That looks OK, just make sure that you finish with 24Bit Long, with the Data in the lower 20Bit locations of the Long.
You can then convert to single.
E
 

jjw

Joined Dec 24, 2013
823
The HB and LB have changed places in temperature and pressure.
Should be:
traw. hb= b(2)
traw. lb =b(3)

praw.hb=b(5)
praw. lb=b(6)
 
Last edited:
Top