Setting up the AK8963C compass module.

Thread Starter

camerart

Joined Feb 25, 2013
1,824
Sorry, I do not do Oshonsoft. In Assembly, one would probably use a bit test on the port (btfss or btfsc = bit test register/port and skip next instruction if set/clear, respectively).

If WAIT does what I suspect, that might be equivalent to "btfss" followed immediately by a command to step back one step (i.e., keep testing the bit until it is set). That will pause everything for the time it takes for the bit to change, but that is not necessary to do. An interrupt based on the bit (say an IOC or INT pin) or a timer rollover (i.e., check once each rollover and do other things in the interim) are two of the ways to avoid that delay.

Of course, in your design, you have other interrupts working, and it is more complex.
Hi J2,
Ah, different languages!
I think you're correct in the way you guess what WAIT does, and I don't think any slight pause will matter too much, so I'll try to do that.
Thanks, C.
 

ericgibbs

Joined Jan 29, 2010
9,570
Hi C,
The ST1 Reg is in the Compass at address 02H, so how can you to connect a hard wired pin between the PIC and the Compass, 02h Bit 0 ??

How are you Reading the Compass Registers.?

E
 

jpanhalt

Joined Jan 18, 2008
8,765
Hi E,

The DRDY pin of the compass module reflects the status of the ST1,0 bit. It does require a connection. However, the datasheet says that the register can be read as an alternative. Of course, reading the register is a bit more complicated. I think C has decided not to read the register.

John
 

Thread Starter

camerart

Joined Feb 25, 2013
1,824
Hi C,
The ST1 Reg is in the Compass at address 02H, so how can you to connect a hard wired pin between the PIC and the Compass, 02h Bit 0 ??

How are you Reading the Compass Registers.?

E
Hi C and J2,
E, there is a choice of checking when the DATA is ready to be READ in the COMPASS chip, either by a PIN or a REGISTER. As READing the REGISTER takes extra steps, and it isn't difficult to add a wire between the DRDY PIN on the COMP to a PIN on the 4620, this is what I did.

Now we have a DRDY PIN connected between both CHIPs.

Am I correct that in the MAIN program I WAIT/WHILE DRDY = 1?
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
9,570
hi John,
As there is a DRDY pin, he can assign a PIC PORT pin in Oshonsoft.
eg:
Assume he uses PORTB.0 , then Oshonsoft allows

Wend
While Not PORTB.0 '' assuming that High = Ready, wait till ready. NOTE: It will wait forever
Wend

E

BTW: Oshonsoft has a Wait command, but really its just a delay loop, time waster.
eg:
WaitMs 100 ' loop for 100 mSec
 

Thread Starter

camerart

Joined Feb 25, 2013
1,824
hi John,
As there is a DRDY pin, he can assign a PIC PORT pin in Oshonsoft.
eg:
Assume he uses PORTB.0 , then Oshonsoft allows

Wend
While Not PORTB.0 '' assuming that High = Ready, wait till ready. NOTE: It will wait forever
Wend

E

BTW: Oshonsoft has a Wait command, but really its just a delay loop, time waster.
eg:
WaitMs 100 ' loop for 100 mSec
Hi,
I carried out the above suggestions, but sorry to say, didn't cure the problem.
Thanks to all.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
1,824
Which suggestion would that be.?:rolleyes:
Look at Post #26, it works.
Hi E,
The suggestion of adding a wire PIN to PIN between the DRDY and the 4620.

When compiling I got an error message, I removed the first WEND and now it compiles.

EDIT:
C
 

Attachments

Last edited:

ericgibbs

Joined Jan 29, 2010
9,570
hi,
Are you actually reading what I post.?
That example clearly shows two different code conditions for testing the BIT

wend , where does this come from.????
while NOT PORTB.0
Wend
 

Thread Starter

camerart

Joined Feb 25, 2013
1,824
hi,
Are you actually reading what I post.?
That example clearly shows two different code conditions for testing the BIT

wend , where does this come from.????
while NOT PORTB.0
Wend
Hi E,
Yes, I read everything posted.

When I said suggestion, it was actually a discussion PAGE1 between me an J2, where I said I would add a PIN wire as it was a preferential way to READ DRDY than READ the REGISTER.

I copied
----------------------------------------------------------------------
Wend
While Not PORTB.0 '' assuming that High = Ready, wait till ready. NOTE: It will wait forever
Wend
-------------------------------------------------------------------------
from your post #25.

I'm using PORTD.0 for DRDY.

While the above is working, thanks, it didn't solve the problem that I had originally. The AK8963C is still intermittently working.

EDIT: I've just re-read many of the posts here, and see that I was using WAIT/WHILE instead of WEND/WHILE, just a little word mixing up.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
1,824
Hi,
I've just run a series of tests, where I disconnected some of the other peripherals in turn, and each time I disconnected the POT INPUTS, I got the error COMP DEG 306.22. As this is an intermittent error, I'll keep checking.

I tried the program previous to the DRDY one, and the tests are the same.

I'll move back to the main thread, unless I need further COMP set-up answers

Thanks, for all the help and sorry for the mix ups E, we got a bit out of sync there I think.
C.
 

jjw

Joined Dec 24, 2013
508
Hi J2,
Waiting for your reply, I came to the same conclusion, that READing the PIN takes fewer steps, so I'll add a PIN.

Is this checked by a WAIT/WEND?
C
While Portx.x=0
Wend
edit: did not read earlier posts, so this was late:)
 

Thread Starter

camerart

Joined Feb 25, 2013
1,824
While Portx.x=0
Wend
Hi J,
Thanks for that, but having carried out a number of tests with DRDY, that didn't work, as mentioned, I tried disconnecting each of the other Peripherals in turn. Dis/Connecting the POT INPUTs to the MAIN PIC, seems to sure the problem.
I've moved back to: https://forum.allaboutcircuits.com/threads/remote-control-by-location-pic-in-oshonsoft.148795/

while I carry out more tests.

I suspect perhaps, it's more electrical, than programming?
C.
 
Top