Finding intermittent faults in PIC PCB Peripherals OSHONSOFT

ericgibbs

Joined Jan 29, 2010
18,848
The image in #14 clearly shows the Clock is inverted to the sense that the Compass is expecting
Data should be Read/Written on the Rising edge of the Clock

Look at Figure 7.2 of the compass d/s
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
The image in #14 clearly shows the Clock is inverted to the sense that the Compass is expecting
Data should be Read/Written on the Rising edge of the Clock

Look at Figure 7.2 of the compass d/s
Hi E,
Yes, FIG 7.2 is within the image posted in #43, but I don't think the clock phase can be changed in the AK8963C COMP.
I'm re-checking.
EDIT:
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi J,
1/ I think J2 has answered this.

2/The analyser shows what's arriving at the MISO PIN, mostly without error, the PIC hasn't been READing the DATA.
These tests are the whole program. You may recall in my other threads, that this COMP module has had a lot of testing, including MAGMASTER the clever calibrating programs, and has given good results, with maybe some errors.
The GPS uses an INTERRUPT, which is ON. This was asked previously, and I tried switching the INTERRUPT of with the same results.
The 18F4620 D/S gives alternatives for the CLK, the AK8953C COMP only has one MODE.
3/ I carried out the i=0 to 7 test, but it gives the same confusing results, as we are looking at.

All of the other peripherals are working, but only the C/S from the COMP is being READ, if I changed the C/S to one of the other modules, then it would be working OK.
C
Do you still have the old working version of the compass program?
Try it without anything in the main program and if it works, use it. You have tried lately HW Spi etc. Maybe something is wrong in the compass setup or somewhere else.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
If you are using SW SPI in the program for the MASTER, change the sense of the clock, INVERT, as @jjw pointed out.
Hi E,
I tried ,SPICLOCK_INVERT =1, see #45 and onward.

I may still be getting mixed up between SW and HW, it's confusing to me.
This is still in the program:
------------------------------------------------
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
SPIPrepare
-----------------------------------------------------
but we stopped using SPICSON/OFF.

It's only been changed since getting the FULL program to work with the COMPASS.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Do you still have the old working version of the compass program?
Try it without anything in the main program and if it works, use it. You have tried lately HW Spi etc. Maybe something is wrong in the compass setup or somewhere else.
Hi J,
At risk of going round in circles. I've been doing this for a year or so, with separate PCBs including the MAGMASTER one, which is a short program, and was working perfectly. Since then we have changed things, such as PCBs, different TRACKS, and SET-UPs, so it would be dangerous to go back, as it would work and maybe give a false positive. If possible I think it would be better to stay with the latest programs, SET-UP, and PCB.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
For SW SPI, Oshonsoft uses SPICSON/OFF as CS , so how are you sending a /CS to the Compass.?
Hi E,
For the BMP280 ALTITUDE C/S
[ Symbol altmtr = LATD.1 'BMP280 BAROMETER/TEMP ]
-------------------------------------------------
SPICSOn
For i = 0 To 23
altmtr = 0 'CHIP SELECT BMP280 ON
adr = 0x88 + i
SPISend adr
SPIReceive data
b(i) = data
altmtr = 1 'CHIP SELECT BMP280 OFF
Next i
SPICSOff
--------------------------------------------------
In an earlier post 'J' asked if the SPICSON/OFF was necessary, so we tried commenting it out, resulted in no change, as if it wasn't needed.

I'm now wondering if some of the replies are at cross purpose, and SW/HW could refer to UART not SPI, as it wasn't shown at the time. Perhaps I'll add SPICSON/OFF back in.

The above form of CODE works for all other peripherals.
C.
 

jjw

Joined Dec 24, 2013
823
Hi E,
For the BMP280 ALTITUDE C/S
[ Symbol altmtr = LATD.1 'BMP280 BAROMETER/TEMP ]
-------------------------------------------------
SPICSOn
For i = 0 To 23
altmtr = 0 'CHIP SELECT BMP280 ON
adr = 0x88 + i
SPISend adr
SPIReceive data
b(i) = data
altmtr = 1 'CHIP SELECT BMP280 OFF
Next i
SPICSOff
--------------------------------------------------
In an earlier post 'J' asked if the SPICSON/OFF was necessary, so we tried commenting it out, resulted in no change, as if it wasn't needed.

I'm now wondering if some of the replies are at cross purpose, and SW/HW could refer to UART not SPI, as it wasn't shown at the time. Perhaps I'll add SPICSON/OFF back in.

The above form of CODE works for all other peripherals.
C.
Hi,
I just tried to change SSPSTAT and SPCON1 to the best of my abilities, but it still errors :(
I'm happy to test any other settings
C
HW/SW was never about UART.
In #34 you said you have tried out different settings in HW SPI. Have you already disabled HW SPI?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
HW/SW was never about UART.
In #34 you said you have tried out different settings in HW SPI. Have you already disabled HW SPI?
Hi J,
Ok, it's only me that got it mixed up then.

Am I correct that when this is used
--------------------------------------------
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
SPIPrepare
--------------------------------------
We're using HWSPI?
If so then that's all I'm using.

Can you give me an example of SWSPI please?

EDIT: It's just coming to me!! Am I correct that when we transferred DATA between MASTER and SLAVE PICs, we uses SWSPI and SSPFUF etc? If so then that's switched off, and we're using SEROUT/SERIN for that DATA transfer.
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi J,
Ok, it's only me that got it mixed up then.

Am I correct that when this is used
--------------------------------------------
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
SPIPrepare
--------------------------------------
We're using HWSPI?
If so then that's all I'm using.

Can you give me an example of SWSPI please?

EDIT: It's just coming to me!! Am I correct that when we transferred DATA between MASTER and SLAVE PICs, we uses SWSPI and SSPFUF etc? If so then that's switched off, and we're using SEROUT/SERIN for that DATA transfer.
C
This has been said a few times before:
Oshonsoft Basic uses SW SPI. It can be used in all PICs. It does not use SPI hardware unit.
Defines for SPI pins, SPI_Send, SPI_Receive are for SW SPI.

SSBUF, SSPCON, SSPSTAT are registers in SPI hardware unit.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
This has been said a few times before:
Oshonsoft Basic uses SW SPI. It can be used in all PICs. It does not use SPI hardware unit.
Defines for SPI pins, SPI_Send, SPI_Receive are for SW SPI.

SSBUF, SSPCON, SSPSTAT are registers in SPI hardware unit.
Hi J,
I know it's been said before, but when it's in writing, as above, although it's appreciated, won't be remembered.
I'll look for some examples of SW/HW in BASIC online.
Thanks.
C
 

jpanhalt

Joined Jan 18, 2008
11,087
I can appreciate your uncertainty about SW and HW SPI. Also note, I know very little about Oshonsoft.

However, if whatever I was doing was using a Special Function Register (SPF), I would consider the communication to be hardware or at least a bastard mix of the two.

Examples:
1571689483124.png
1571689539036.png
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
I can appreciate your uncertainty about SW and HW SPI. Also note, I know very little about Oshonsoft.

However, if whatever I was doing was using a Special Function Register (SPF), I would consider the communication to be hardware or at least a bastard mix of the two.

Examples:
View attachment 189375
View attachment 189376
Hi J2,
After reading E's manual examples, I'm pretty sure that SSPSTAT and SSPCON1 are HWSPI so it's me that's mixing them. J's reply [ NO ] to my question in #38 confused me because of my ambiguous question [NOT}
Thanks,
C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
From the manual and help, I see 2x examples:
[ SPICS_INVERT - (default value: 0, allowed values: 0,1) ]
and
[ That can be changed by assigning the value 1 to SPICLOCK_INVERT ]

I'm guessing the J's suggestion earlier of [ 1 ] is correct.

If [ SPICLOCK_INVERT =1 ] is used, the Analyser shows [ "The initial (idle) state of the CLK line does not match the settings" ]
If I change the analyser to suit, all of the other peripherals won't work.
In Oshonsoft, can [ SPICLOCK_INVERT =1 ] be used just before COMP READ then [ SPICLOCK_INVERT =0 ] be added just after the READ. Would this work?
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
1) I don't know

2) Do you see in the analyzer is the MISO stuck at low or high when faulty results are coming or is some but faulty data seen ?
Are these tests of the whole program or just the compass?
Are the interrupts enabled?
Is the clock polarity specified in D/S ?

Try a test with reading only registers 0x80 -0x87
For i=0 to 7
addr=0x80+i
......
etc.
Data from 0x80 is device I'd=0x48
Hi J,
I have edited the image in #43 to show the RECEIVED BYTE from 0x80 SEND. It shows [ 0x48 ] the CHIP ID.

NOTE: The top analysis is when the COMP is working, and the bottom one is from a none working analysis. To me they look the same

So the DATA is arriving at the PIC MISO PIN. Which means that the COMP is working.

This doesn't alter what still looks like a possible Clock phase problem.
C.
 

jjw

Joined Dec 24, 2013
823
Is it po
Hi,

Hi J,
I have edited the image in #43 to show the RECEIVED BYTE from 0x80 SEND. It shows [ 0x48 ] the CHIP ID.

NOTE: The top analysis is when the COMP is working, and the bottom one is from a none working analysis. To me they look the same

So the DATA is arriving at the PIC MISO PIN. Which means that the COMP is working.

This doesn't alter what still looks like a possible Clock phase problem.
C.
Is the analyzer picture a screen capture from a PC?
Is it possible to have it with a better resolution and some other format than jpg, for example png or gif
The picture is now mostly unreadable.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Is it po

Is the analyzer picture a screen capture from a PC?
Is it possible to have it with a better resolution and some other format than jpg, for example png or gif
The picture is now mostly unreadable.
Hi J,
Yes, a screen shot from a pc.
I wonder if the problem is because of re-shaping a long picture.
Here's a more square section in JPG and PNG
Can you describe both please?

If I click on the posted images, I can see them clear enough to read the BYTES
C
 

Attachments

Top