What's the difference between READing and polling?

Thread Starter

camerart

Joined Feb 25, 2013
2,802
Hi,

I've just come across this line from a D/S: [ Read ST1 register (not needed when polling ST1) ]

What's the difference?
Camerart.
 

BR-549

Joined Sep 22, 2013
4,938
A read is immediate. A poll is on a schedule. The read from a poll....is stored in an assigned area, and then updated.
 

Thread Starter

camerart

Joined Feb 25, 2013
2,802
A read is immediate. A poll is on a schedule. The read from a poll....is stored in an assigned area, and then updated.
Hi B,
I should have said that I'm using Oshonsoft BASIC

What I'm trying to do is POLL BIT0 of the ST1 REGISTER
Here's is how I imagine it would look like (Section of CODE)
_________________________________________________________
compss = 0 'CHIP SELECT COMPASS ON
SPISend 0x02 'st1 register
SPIReceive st1
compss = 1 'CHIP SELECT COMPASS OFF


If st1.0 = 1 Then do something '[[[[[[ drdy = BIT0 ]]]]]
_________________________________________________________
but in the D/S is says that I don't need to carry out the bit in RED, but 'simply' poll bit '0'
Oshonsoft has rejected: 'DEFINE ST1 as 0x02 DEFINE is not a correct word.

C.
 

BR-549

Joined Sep 22, 2013
4,938
I thought it was just a general question. I am not familiar with that basic language, or the chip.

Stick around, there are experts on here.
 

jpanhalt

Joined Jan 18, 2008
11,088
This from the datsheet may add context:
6.4.3.2. Normal Read Sequence
(1) Check Data Ready or not by any of the following method.
- Polling DRDY bit of ST1 register
- Monitor DRDY pin
When Data Ready, proceed to the next step.
(2) Read ST1 register (not needed when polling ST1)
DRDY: Shows Data Ready or not. Not when “0”, Data Ready when “1”.
DOR: Shows if any data has been skipped before the current data or not. There are no skipped data when “0”, there are skipped data when “1”.
As for "(2)", you can poll the DRDY pin instead of the bit in ST1. By polling the bit, one is reading the register, so reading the register becomes superfluous. Reading the pin does not read the register. Thus, it appears that ST1 must be read, but why?

My original impression was that ST1 needed to be read in order to reset some flags. By analogy, compare that to reading RCREG in a mid-range PIC in order to change a status flag. However, I cannot find that statement supported per se in the datasheet. It does appear that ST2 behaves that way.
 

jjw

Joined Dec 24, 2013
726
Hi B,
I should have said that I'm using Oshonsoft BASIC

What I'm trying to do is POLL BIT0 of the ST1 REGISTER
Here's is how I imagine it would look like (Section of CODE)
_____________________________________________________________________
compss = 0 'CHIP SELECT COMPASS ON
SPISend 0x02 'st1 register
SPIReceive st1
compss = 1 'CHIP SELECT COMPASS OFF


If st1.0 = 1 Then do something '[[[[[[ drdy = BIT0 ]]]]]
_________________________________________________________________________
but in the D/S is says that I don't need to carry out the bit in RED, but 'simply' poll bit '0'
Oshonsoft has rejected: 'DEFINE ST1 as 0x02 DEFINE is not a correct word.

C.
You can connect the rdy pin of the compass to a port pin of the PIC and read the state of the pin.
Or read the the register 0x02 and check it' s bit0
Polling means you read repeatedly the bit until it goes ON
The D/S says, that the overflow bit has also to be checked before x, y, z can be read.

Something like this might work:

drdy=0
While drdy <> 1
-Read drdy from address 0x02 ' SPI read
drdy= drdy And %00000011 ' mask overflow and ready
Wend
.... read x, y, z

Define does not work with constant values
 

Thread Starter

camerart

Joined Feb 25, 2013
2,802
Hi J n JP,
Ok,
I'll keep the RED section in and READ ST1, then [ If st1.0 and if st1.1 then 'do something' ] and see what happens.
Thanks.
C.
 
Top