Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi,
I'm puzzled!
I'm trying to READ the Altimeter measurement data for the registers. The D/S suggests BURST READ.
I've tried individually, and it appears that there is nothing in the registers, note: 2x of them are 0x80, which I can see.
If they are being READ as a series, how do I READ them? Is SSPBUF still involved?
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi,
I'm puzzled!
I'm trying to READ the Altimeter measurement data for the registers. The D/S suggests BURST READ.
I've tried individually, and it appears that there is nothing in the registers, note: 2x of them are 0x80, which I can see.
If they are being READ as a series, how do I READ them? Is SSPBUF still involved?
C
It worked without burst mode in the old program.

Check the control register 0xF4
Table 22: register settings osrs_t
osrs_t[2:0] Temperature oversampling 000
Skipped, output set to 0x800000

Same for osr_p[2:0]
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
It worked without burst mode in the old program.

Check the control register 0xF4
Table 22: register settings osrs_t
osrs_t[2:0] Temperature oversampling 000
Skipped, output set to 0x800000

Same for osr_p[2:0]
Hi J,There's a lot going on, but If you look at the attachment in #1050 you will see all of my settings for F4 and F5 are there including a test only for an F7 READ.
I notice that today, the CTRL_MEAS READing has gone to '0', so unreliable.

I'm now looking closer at #1062, as I think this may help the timing. The READing must be READ within o.5ms, as I understand it?
C
 

jjw

Joined Dec 24, 2013
823
In #1050 you have chip select from OSH ( SPICsOn ) and altmeter cs=0.
I don 't know which pin is for OSH SPI, but don't use both.
Do you still have the working version for BMP280?
Start from it.
Reading code from a .jpg is a bit difficult, better attach .bas or . txt
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
In #1050 you have chip select from OSH ( SPICsOn ) and altmeter cs=0.
I don 't know which pin is for OSH SPI, but don't use both.
Do you still have the working version for BMP280?
Start from it.
Reading code from a .jpg is a bit difficult, better attach .bas or . txt
Hi J,
Yes, the image is a bit congested, and shows I used OSH for that test, just below the OSH section is a commented out SSPBUF section. I've tried lots of different variations.

Using SSPBUF, I succesfully set and READ the I.D. , F4 and F5.

The 'working version' as you call it refers to an earlier OSH program, that has now been superceded, by a working SSPBUF program, allthough the measurement data is not being set by the chip yet. I think STATUS needs to be used.

What is the sugnificance of ' Skipped, output set to 0x800000 '

Next I'll show the working SSPBUF CODE along with results.
C
Code:
'BMP280 UTILITIES
'Initialize ALTMTR BMP280
'RESET
Proc init_altmtr()
'WRITE SET UP REGISTERS

'WaitMs 50
altmtr_cs = 0
    wr_adr = 0x60  'WRITE 0xE0 %01100000 RESET ADDR [Is this needed?]
    wr_byte = 0xb6  '%10110110 resets BMP280 = 0x00
Call periph_wr(wr_adr, wr_byte)
'altmtr_cs = 1
'WaitMs 2  'Time to settle?????????????????????
'----------------------------------
'CTRL_MEAS
'WaitMs 50
altmtr_cs = 0
    wr_adr = 0x74  'WRITE 0xF4 %01110100 Control CTRL_MEAS reg addr
    wr_byte = 0xb7  '0xB7 %10110111 P/ON T/ON Px16 Tx2  Normal Mode
Call periph_wr(wr_adr, wr_byte)
'altmtr_cs = 1  'added????????????
'-------------------------------
'CONFIG
'WaitMs 50
    wr_adr = 0x75  'WRITE 0xF5 %01110101 Control CONFIG reg addr
    wr_byte = 0x10  '%00010000 t_sb 0.5ms Table 11-11R filter x16 table 6
'altmtr_cs = 0
    Call periph_wr(wr_adr, wr_byte)
altmtr_cs = 1
'----------------------------

'READ SET UP REGISTERS
altmtr_cs = 0
id = periph_rd(0xd0)  'ID
altmtr_cs = 1  'Too fast for digital analyser to see!!

altmtr_cs = 0
ctrl_meas = periph_rd(0xf4)
altmtr_cs = 1

altmtr_cs = 0
config = periph_rd(0xf5)
altmtr_cs = 1
Hserout "ALT SHOW  ID 0x58 88  =", #id, "  CTRL_MEAS B7 or 183 =", #ctrl_meas, "  CONFIG 0x10 or 16  =", #config, CrLf, CrLf

End Proc
 

jjw

Joined Dec 24, 2013
823
Output of the temperature and pressure registers is set to 0x800000 if
the osr bits ( three bits ) are set to binary 000
I thought this might be reason, when you get 0x80, 0x00 readings.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Output of the temperature and pressure registers is set to 0x800000 if
the osr bits ( three bits ) are set to binary 000
I thought this might be reason, when you get 0x80, 0x00 readings.
Hi J,
Both OSRS_T and OSRS_P are set to 101.

All of the F4 and F5 settings are in the comments of the CODE in #1066
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi,
At one point it was READ the Compass and Altimeter ok. Also the Settings registers, shown on the attachment at the top.
But this all is intermittent, and and previously mentioned probably timing.

I tried adding the STATUS BIT, but I don't think I did it correctly.

Is this the correct way to do it?
'While STATUS.0
'Wend
While STATUS.3
Wend
and where exactly should they go? I can't put them in the FUNCTIONS as they are also for the Compass.

I tried various options, but none was successful
C
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
Hi,
At one point it was READ the Compass and Altimeter ok. Also the Settings registers, shown on the attachment at the top.
But this all is intermittent, and and previously mentioned probably timing.

I tried adding the STATUS BIT, but I don't think I did it correctly.

Is this the correct way to do it?
'While STATUS.0
'Wend
While STATUS.3
Wend
and where exactly should they go? I can't put them in the FUNCTIONS as they are also for the Compass.

I tried various options, but none was successful
C
I don't understand anything about the attachment without seeing the program.
I think it would be better to concentrate first only on the BMP280 and when it works on the compass.
Take from the old working program the SPI setup ( clock polarities, speed etc ) and the BMP280 measuring setup.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
I don't understand anything about the attachment without seeing the program.
I think it would be better to concentrate first only on the BMP280 and when it works on the compass.
Take from the old working program the SPI setup ( clock polarities, speed etc ) and the BMP280 measuring setup.
Hi J,
The attachment is from the BMP280 D/S shhowing when the DATA has been READ by it.

Take from the old working program the SPI setup ( clock polarities, speed etc ) and the BMP280 measuring setup.
This is what I've been doing, and have got it working, but intermitently, so at the moment, I'm looking at why this happens.
Thanks.
C.
 

jjw

Joined Dec 24, 2013
823
msg #350 two and half years ago has a program you said was working.
wr 0x74 , 0xFF
wr 0x75, 0x1C

Have you done hwSPI setup and bmp280 SPI setup?
 
Last edited:

jjw

Joined Dec 24, 2013
823
#350 2,5 years ago has a program you said was working.
wr 0x74 , 0xFF
wr 0x75, 0x1C

Have you done hwSPI setup and bmp280 SPI setup?
BMP280 SPI setup is automatic, but in the PIC CKE and CKP bits have to be 00 or 11.
Check also SMP bit, 0 data sampling at the middle, 1 at the end of the output data.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
msg #350 two and half years ago has a program you said was working.
wr 0x74 , 0xFF
wr 0x75, 0x1C

Have you done hwSPI setup and bmp280 SPI setup?
Hi J,
The #350 program works, but it is in OSH format, we are switching to HW-SSPBUF format. I tried modifying a woking program fro OSH to HW, but after reading the BMP280 D/S notice it isn't quite the same.

In CODE is the SPI set-up.
Code:
'MODE 0,0
SSPSTAT.SMP = 0  'Input data sampled at middle of data output time
SSPSTAT.CKE = 0  '1 Output data changes on clock transition from idle to active
SSPSTAT.5 = 0  'I2C only
SSPSTAT.4 = 0  'I2C only
SSPSTAT.3 = 0  'I2C only
SSPSTAT.2 = 0  'I2C only
SSPSTAT.1 = 0  'I2C only

SSPCON1.WCOL = 0  'Collision detect
SSPCON1.SSPOV = 0  'Overflow
SSPCON1.SSPEN = 1  'Configure SCK,SD0,SDI,/SS
SSPCON1.CKP = 1  '[1]  'Clock Idle high, Active low [Clock Idle Low, Active High]
SSPCON1.SSPM3 = 0  '0010 = SPI Master mode, clock = FOSC/64
SSPCON1.SSPM2 = 0
SSPCON1.SSPM1 = 1
SSPCON1.SSPM0 = 0
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
BMP280 SPI setup is automatic, but in the PIC CKE and CKP bits have to be 00 or 11.
Check also SMP bit, 0 data sampling at the middle, 1 at the end of the output data.
Hi J, In #1074 it can be seen that:
SMP = 0 'Input data sampled at middle of data output time
CKE = 0 '1 Output data changes on clock transition from idle to active
CKP = 1 '[1] 'Clock Idle high, Active low
According to above, this is wrong, and produces this: attached:

C.
 

Attachments

jjw

Joined Dec 24, 2013
823
If in the analyzer picture the input data is sampled on falling edge of the clock, it seems that the sample is taken very near of the changing data bit.
This could cause intermittent errors?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
If in the analyzer picture the input data is sampled on falling edge of the clock, it seems that the sample is taken very near of the changing data bit.
This could cause intermittent errors?
Hi J,
This has always been complicated, but I thought I had it correctly.
The attachment shows DATA READ at middle, CKE and CKP both set to 1.
I may have been mistaken when looking at the Analysis, as the MOSI signal is when CLK goes from H to L and MISO goes from L to H. Is this ok?
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Does it work now?
Hi J,
Both Compass and Altmtr are now all incorrect.

EDIT: Both tests:
SMP=0 = Input data sampled at middle of data Output time
CKE and CKP set to 11 and 00
Doesn't work.

I returned it to:
SMP=0
CKE= 0
CKP= 1
working again?

It still has the error previously mentioned and why I'm checking STATUS.

C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Does it work now?
Hi J,
I've been getting an intermittent error, posted in other threads, but it appears to be solved. There was a RESET at the start of the BMP280 initialisation, which shouldn't have been there, now removed, the problem seems gone, so onward and upward.
C
 
Top