This email chronicles the process of debugging the board, and finally discovering that the thing we thought was a bug, was in fact caused by Mik’s choice of inappropriate SPI test sequence.

David Carkeek

Jul 18 (4 days ago)

to me
By the way, I don’t know if the coulomb counter is connected to power. U8 is connected if R1008 is installed.

Inline image 1
Anyway, I don’t have any hardware to try out. I’m just getting started on TS06.4, or TS06.3.2, however they are being designated.

On Sat, Jul 18, 2015 at 4:01 PM, Mik Lamming <mik@lamming.com> wrote:

Mik Lamming mik@lamming.com

Jul 18 (4 days ago)

to mik110.ts06David
Well it’s responding to the I2C, but the voltage and temperature readings look bogus. 
Actually I don’t care at the moment.  I just wanted to get the I2C test code working before I moved on.  Also you can use the I2C code as a model if you want to try your hand at programming.
I didn’t answer your IDE question yesterday.  I think I’d install the bootleg IDE we got, and use that.  You just install it and off you go.  You need the bootleg one because our code is too big for the eval. version.
Fresher meat – fixed a few cosmetics.  

https://drive.google.com/open?id=0B1iBvkbdWzq0Z29FV2wzR2NOeUE

I’m stopping futzing with the test program now.  It will allow you to figure out what’s working, and not, and to jiggle a few pins so you can scope things out if something is broken.

Mik Lamming mik@lamming.com

Jul 18 (4 days ago)

to Davidmik110.ts06
Nomenclature – I don’t care how we name things.   It’s more a practical issue for me.  I need to generate a new name when I have to make a new header file.  If you change any pin designations in this design, then we will have a TS06.4.  If they stay the same, then it can be a TS06.3b, or TS06.3.1, or…

David Carkeek

Jul 20 (2 days ago)

to me
Inline image 2
One more board built. I had some trouble with the new solder paste. It’s excellent paste and flows very easily. Since it flows easily it goes underneath the stencil and creates messy blobs in most places instead of well-defined shapes on each pad. The result was too much solder in some places but it was easy to touch up with an iron. I’m still frustrated by the paste application process.
What is your schedule for this week? How will I get this board to you? Or do you need it?
Is there value in having one of the new boards in an enclosure with a battery? I got the power supply working a little better but now the first regulator won’t drive the second regulator when the input voltage is higher than about 1.2V. It needs to work with a 5V input to charge the battery from USB, so I have to do more troubleshooting. Now the first regulator is bypassed so battery charging is not an option. Since the RF performance is not likely to be good (because of metal close to the antennae) having an enclosure doesn’t seem important at the moment. I cut out the GND plane underneath the DW on this board so there is more chance of it working better.

David Carkeek

Jul 20 (2 days ago)

to me
What do we have so far? Is this correct?

TS06.1: Perf board with RayTac module
TS06.2: Perf board with Raytac and DecaWave modules connected 
TS06.3: PCB to fit Serpac enclosure, adding switching power supply, USB, IMU, atmospheric pressure sensor, uSD socket, buttons
Future
TS06.4: Improvements to TS06.3
TS06.5: Shrink size of TS06.4 to fit in a wrist band
TS06.6: Improvements to TS06.5
TS06.7 or TS07.1: First big, clunky attempt at a ring
What do you want to take to CES? There are only four months left for development.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
That’s stupendous work.   Yaaaaaay!  Relieved that the test program worked.

This solder paste process is clearly hard.  Seems like there ought to be some way to keep the stencil stuck to the PCB, like you first spray it with some sort of mild adhesive.

I can certainly manage with what I have already.   My preference is to have at least 3 identical units, so I can make sure code can range more than one unit at once.  Then I don’t have to maintain .02 and .03 software in order to do testing.  Having battery-powered device is not as high on list as having 3 x TS06.3. 
Since battery charging is not an option, I’d say don’t let’s bother until you have it worked out.
Notice that the LTC2941 is not providing sensible voltage or temp.  I left that as a programming challenge, in case you wanted to futz.
Frustration with the DW library has got me to the point of swearing loudly.  After a sleep, I decided that I’d completely re-write the DW library.  Theirs is so hideously convoluted that it’s hard to figure out what’s going on when packets start flying.  It shouldn’t take more than a day or so, and then I’ll really know what’s going on.

David Carkeek

Jul 20 (2 days ago)

to me
Is the present code set up for using the Xtal clock or RC clock?

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
Hope it was clear from my message that 2 x 6.2  and 2 x 6.3 is enough for me to work with.  3 x 6.3 is better, and 4 x 6.3 is not worth the effort.

I can pick up a board this week sometime.  I’ll make it work.
Brenda was delayed by more than 24 hours and won’t be back till 7pm tonight.

David Carkeek

Jul 20 (2 days ago)

to me
You are leaving for the UK one week from today. Amy is moving this weekend so I will probably go to LA this Saturday. I will start working on another board tonight.

David Carkeek

Jul 20 (2 days ago)

to me
If you exceed the 16k RAM barrier then you will only be able to use TS06.3. If you need more I can always send them to you.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
TS06.4 ought to say something about power harvesting
Otherwise that list looks right to me.

I think for CES – a finished ring with gold and silver options, stick-on versions for things, and power-harvesting thumb-sized anchors.   Software will remind you of lost objects by telling you to within 10cms where they are located, and will distinguish falling down in the abthroom, from gorvelling around on the floor for a lost earring.  Early detection of Alzheimer in infants will be extra.

I’m thinking that early customers (if any) would be behavioral scientists, marketeers.  But having customers is a double-edged sword.

I think it would be cool to think of a company/person we would like to engage at CES, and then think of the kind of some cool demo that would get their attention.  Need to think on that.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
I think it’s RC.  Do you want me to change it?

Rename old version to RC, and uploaded new version XT

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
OK.   As soon as I know Brenda’s car schedule I’ll plan a (lunchtime?) trip to AVAGO, or whatever suits.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
Ah – that’s true.   I only have BLE code OR  DW code running at the moment.  BLE AND DW code may break the bank, but maybe the anchors only need DW for a while.

David Carkeek

Jul 20 (2 days ago)

to me
The DW test passes with the XT version. There is power supply noise on the crystal waveform when the switching power supply is running. I don’t know what the impact of that will be on the RTC accuracy.

I wonder why the SPI on board you have didn’t work with the XTAL clock.
During SPI loop there is no signal on spimosi but there is on spimiso. During the decawave test there is activity on spimosi. Is that right?
But the decawave test does pass using the XT program.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to Davidmik110.ts06
That’s interesting.  So there must be some hardware problem with this board fer sure then.

The list of things that will affect performance is very long (I’m starting to make a list on the blog), and RTC accuracy is low on the list.  I’m focusing on making it work at all.
During SPI loop I’m simply asking the DW for the contents of register #0.   The fact that the test prints out DECA0130 proves it’s working.  I chose this register because the bit patterns for this transaction are described exactly on p11 of the DW1000 User Manual.   
Inline image 1
The DW IRQ line won’t get used on that test.
If GPIO 5/6 are floating then  PHA and POL are read as ‘0’.  In that case 1-bits are positive-going, and 0-bits are zero.  That has to be correct because you are getting good data back.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
I created two new versions of the test program, using Xtal, and RC.   I’ll make it a CLI feature eventually.   Each says what clock it is using.

https://drive.google.com/open?id=0B1iBvkbdWzq0OG12NV9DM3ZUdWs

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
Oh to hell with it.  It was easier to add a new command, than to make myself a note to remember to do it.

Notice new command “c” which toggles the clock source.

David Carkeek

Jul 20 (2 days ago)

to me
I didn’t bring the board to work because I have an appointment for a routine physical at 2:15 and I’ll probably go home after that. I didn’t get to the office until 11:30. Probably should have just stayed at home. Nobody would have known or cared.

Anyway, I’ll check it later today.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
No hurry.  Just getting things off my TODO list

David Carkeek

AttachmentsJul 20 (2 days ago)

to me
That clock selector in your test program is totally cool!
Waveforms look identical with XTAL or RC clock.
The scope screen is copied to a USB drive if it is inserted in the front of the scope when the Print button is pressed on the front panel.
Ch1: m_spicsn
Ch2: m_spiclk
Ch3: m_spimosi
Ch4: m_spimiso
Still no MOSI activity observed during the SPI test loop.
Scope screen captures
4: DecaWave test, triggered on MOSI, entire sequence
5: DecaWave test, triggered on MOSI, zoomed in to first part of sequence
6: spi test, triggered on MOSI (no trigger)
7: spi test triggered on cs, showing one complete loop
8: spi test, triggered on cs, zoomed in
MOSI is clearly working correctly because the DW test passes, and it looks normal during the DW test. There’s no MOSI activity during the spi test loop.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
That scope feature is cool.
I’m at SFO collecting Brenda who is 30 hours late.
More when I get home

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
OK, now I’m really confused.  I sure can see that there is nothing on the trace.  But how can that be?

The very first transaction of the DecaWave test is identical to the first transaction of the spi test.
case ‘d’ :
TS_TRACE(“decawave… rn”); ts_flush();
SPI_master_poll_init();  // initialize the DW SPI channel
uint32_t devID = dwt_readdevid();
                                                ….
case ‘s’ :
TS_TRACE(“spi-looprn”);  ts_flush();
SPI_master_poll_init();  // initialize the DW SPI channel
while (NRF_UART0->EVENTS_RXDRDY != 1) {
uint32_t devID = dwt_readdevid();
                                                ….
By definition, everything is the same right up to the case statement, and then the only difference is the extra test to see if the UART has input.  I just can’t believe that has any impact.
MISO has no pullup specified at the Nordic end.
The code is the same for both 6.2 and 6.3.   Maybe I should put the scope on 6.w and see what gives?
I can’t actually understand the scope traces.  dwt_readdevid();  produces a 5-byte transaction under a constant chipsel.  (It kind of helps to overlap the clocks and the data slightly so that you can tell where the bits are. )  There should be one MOSI byte (0), followed by a train of 4 MISO bytes (0x30 0x01, 0xca, 0xde).  I believe that picture #8 is showing the right MISO pattern, but I don’t understand why there is no MOSI.
Can you find a similar pattern in the DecaWave test?
Would it help if I turned an LED on at the beginning of the sequence as a trigger?

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
I tried SPI using RC vs Xtal, and it consistently fails on the Xtal, and works on the RC.

Mik Lamming mik@lamming.com

Jul 20 (2 days ago)

to David
I wasn’t clear.  Scope image #8 has the right bit pattern, but the first byte ought to appear on MOSI, but it is appearing on MISO.  Is that a clue?

David Carkeek

Jul 21 (1 day ago)

to me
For some reason the first board didn’t work with the crystal and then I seem to have fucked it up worse (probably damaged the module) with my probing. Maybe I had the wrong value capacitor on the crystal. I think changing the module is necessary at this point.

David Carkeek

AttachmentsJul 21 (1 day ago)

to me
I don’t know if I am doing this correctly. At least I am getting hex values.

9 – dw test first four bytes
10 – dw test last three bytes
11 – spi loop.

David Carkeek

Jul 21 (1 day ago)

to me
MOSI ought to be the easiest to get right because it is coming from the Nordic. Right? How could there be anything coming back from the DW if it isn’t getting written to? So there *must* be data coming out of the Nordic during the spi loop I think. But I can’t see it.

Can we start with something simpler, if that is possible? Is the code easy enough for me to understand that I could fiddle with it?

David Carkeek

AttachmentsJul 21 (1 day ago)

to me
Screen captures 9 and 10 (previous email)
CS polarity: Negative
Trigger on falling edge of CS
Width: 8
Order: MSB
These settings don’t seem to change the result:
Endian: Off
View packets
Data: MOSI
Screen captures 13 and 14: same settings except Order: LSB
Screen capture 12 shows the conversion table.

David Carkeek

Jul 21 (1 day ago)

to me
Why is the length of byte 4 (starting from 0) longer than the others?

Are there supposed to be just 7 bytes?

David Carkeek

AttachmentsJul 21 (1 day ago)

to me
Sorry for sending garbage. At least one of these settings might be correct but I don’t know which one.

15, 16: Data polarity 1, MSB
17, 18: Data polarity 0, LSB
You can see the bit order and polarity on the screen capture.
There are pull-down resistors on the SPIPOL and SPIPHA DW module pins.

Mik Lamming mik@lamming.com

9:48 AM (22 hours ago)

to David
A bit of straw clutching…

https://drive.google.com/open?id=0B1iBvkbdWzq0V21NZmloZmtKdDA

Please try this version with Deca and SPI tests and send me the reports which should look something like this:
> decawave…
clk:14 mosi:10 miso:12
Respond on SPI  OK.
ID=’deca0130′   OK.
DW_LED(2)       OK.
Temp= 23.00C    OK
Volts= 3.30     OK
Upload data     OK.
RF transmit     OK.
DW interrupt    OK.
> spi-loop
clk:14 mosi:10 miso:12

David Carkeek

9:55 AM (22 hours ago)

to me
Inline image 2

A bit different than expected.

David Carkeek

Attachments10:30 AM (22 hours ago)

to me

David Carkeek

Attachments10:31 AM (21 hours ago)

to me

Mik Lamming mik@lamming.com

12:03 PM (20 hours ago)

to David
https://drive.google.com/open?id=0B1iBvkbdWzq0aUxGMVJXUDdWTlE

New spitest reads status register.  which should output 0x15 on MOSI and read 4 bytes back in on MISO.  Also reports PHA, POL, and bit order.
On termination it prints the last status, so you know what you were probably should have seen in the 4 bytes.

David Carkeek

Attachments12:59 PM (19 hours ago)

to me
Looks like I didn’t hit send. This shows the hold time for a rising and falling edge.

Mik Lamming mik@lamming.com

3:20 PM (17 hours ago)

to David
20ns?  That seems quite slow

David Carkeek

4:10 PM (16 hours ago)

to me
But SPI is a slow interface.

Nordic datasheet:
Inline image 1
SCK to Data Hold is 10ns so we are OK.

David Carkeek

4:12 PM (16 hours ago)

to me
Wrong page. Here is the SPI master spec.

Inline image 1

Mik Lamming mik@lamming.com

5:31 PM (14 hours ago)

to David
I’m only running the SPI at 125Kbps.  Will it be OK when I crank up to 4, or 8Mb/s ?

I suppose I should make BPS another option in the test program.

David Carkeek

5:45 PM (14 hours ago)

to me
It should be OK. The slew rates are slow and the board traces are short.

Mik Lamming mik@lamming.com

7:13 PM (13 hours ago)

to David
https://drive.google.com/open?id=0B1iBvkbdWzq0UWVhdEpiblZGeWs

Couple of minor bug-fixes to test program.
The OFF command doesn’t send it to permanent sleep now. 🙂  and RESET will wake it up again.  Good for testing power.
SPI prints out all SPI params including speed
> spi-loop
CLOCK:14;       MOSI:10;                  MISO:12
POL:’-‘;             PHA:falling edge;       ORDER:lsb
SPEED: 125kbps.
The “Doh!” moment.  At this point we have a phone call.   David points out that it looks to him like Mik’s software is (correctly) sending all zeroes on the MOSI line, and that’s why we don’t see any activity on MOSI.  (There are times when I despair about my stupidity.)  Mik changes the test program to do something that produces signals on the MOSI

Leave a Reply