Missing SPI Clock Pulses

Started by sfyffe, June 18, 2015, 07:45:54 AM

sfyffe

Hello Everyone,

I am trying to get the SPIFlash library to work based on an Atmega644A (8mHZ Optibootloader) and an ISSI ( IS25LD040) SPI Flash which is a crossover to the Winbond (W25x40) chip.   Basically I can not access the chip.

When I setup my Moteino to access the memory and capture the SPI bus I get the trace in the attached image named moteinoSPI.jpg.   This shows the clock pulses but MOSI and MISO are not shifting.

When I get my custom board setup to access the memory I get the trace shown in customSPI.jpg where I never get clock pulses to shift the registers.   I do get CS to pulse low though.

This is all using the basic spi flash read write program Felix wrote with only a single line change where I removed the optional MANUFACTIRE_ID as follows:

SPIFlash flash(FLASH_SS);

My manufacture ID is 0x9D7F according to the datasheet.   Passing my chips ID would cause init to fail.   I am sure because the clock is missing..


Thanks for any help,

Stephen







TomWS

I suggest that you use the schematic (and code modifications) for the Moteino Mega as this more closely matches the processor that you are using.

Tom

sfyffe

Thanks for the response Tom.

I worked on this over the weekend.  I was not able to get the DualOptiBoot bootloader burned in.   Avrdude was always ending with a verification content mismatch after setting the lock bits that I could not understand and resolve.

This did get me to look at the differences between the Moteino Mega and my board.   The electrical connections were the same.  Not really much to get wrong there.   I am however  running this controller with an 8MHz crystal and an 8MHz Sanguino Optibootloader from Lauszus.   This all seems to work well running a variety of other programs.

I wound up swapping out the 8MHz crystal for a 16MHz crystal and burned the 16MHz Sanguino bootloader.   Loaded up the SPI Flash demo program I have and all worked well.

I did confirmed my fuses and that the build.f_cpu was set correctly in boards.txt.    I would like to use the 8MHZ crystals as I have a pile of them leftover from another project.

What in the booloader and build environment could cause this not to work? 


Stephen



Felix

The different bootloader should have nothing to do with it.
Also half the CPU frequency should be OK.
So at least I don't think those 2 things are at fault.

TomWS

Quote from: sfyffe on June 22, 2015, 07:34:22 AM
Thanks for the response Tom.

I worked on this over the weekend.  I was not able to get the DualOptiBoot bootloader burned in.   Avrdude was always ending with a verification content mismatch after setting the lock bits that I could not understand and resolve.
This is probably an artifact that AVRDUDE can only program 3 of the extended fuse bits and the remaining 5 bits always read as a 1 causing a mismatch between what you think you want to program and what AVRDUDE reads back.  If the difference is with these upper bits then the message can be reliably ignored.

Quote from: sfyffe on June 22, 2015, 07:34:22 AM
This did get me to look at the differences between the Moteino Mega and my board.   The electrical connections were the same.  Not really much to get wrong there.   I am however  running this controller with an 8MHz crystal and an 8MHz Sanguino Optibootloader from Lauszus.   This all seems to work well running a variety of other programs.

I wound up swapping out the 8MHz crystal for a 16MHz crystal and burned the 16MHz Sanguino bootloader.   Loaded up the SPI Flash demo program I have and all worked well.

I did confirmed my fuses and that the build.f_cpu was set correctly in boards.txt.    I would like to use the 8MHZ crystals as I have a pile of them leftover from another project.

What in the booloader and build environment could cause this not to work? 


Stephen
When using 8MHz you'll need to add a new board entry to the boards.txt file to change the UART upload speed to 57,600 as the normal 115200 doesn't work reliably at 8MHz.  Also, you could use the internal oscillator and avoid a crystal altogether unless you have tight timing constraints that require a crystal.

Tom
Here is the board section I've added for running 8MHz internal oscillator:
##############################################################
MoteinoLP.name=Moteino8MHz
MoteinoLP.upload.tool=avrdude
MoteinoLP.upload.protocol=arduino
MoteinoLP.upload.maximum_size=31744
MoteinoLP.upload.speed=57600
MoteinoLP.bootloader.low_fuses=0xE2
MoteinoLP.bootloader.high_fuses=0xDA
MoteinoLP.bootloader.extended_fuses=0x05
MoteinoLP.bootloader.path=Moteino
MoteinoLP.bootloader.file=DualOptiboot_V5.0_atmega328_BlinkD9.hex
MoteinoLP.bootloader.unlock_bits=0x3F
MoteinoLP.bootloader.lock_bits=0xCF
MoteinoLP.build.mcu=atmega328p
MoteinoLP.build.f_cpu=8000000L
MoteinoLP.build.core=arduino:arduino
MoteinoLP.build.variant=arduino:standard
MoteinoLP.build.board=AVR_MOTEINO