- Netduino Forums
- → todotani's Content
todotani's Content
There have been 3 items by todotani (Search limited from 21-April 23)
#3056 SPI flash memory issue
Posted by todotani on 27 September 2010 - 07:29 PM in Netduino 2 (and Netduino 1)
#3008 SPI flash memory issue
Posted by todotani on 27 September 2010 - 11:52 AM in Netduino 2 (and Netduino 1)
I'm trying to handle AT45DB161D SPI flash memory using the following code and could not read status/ID info correctly.
The test code read only status register and device ID (read/write data block is not implemented yet).
The read value from this test code resulted 0xFF, not expected value.
However, the same code worked as expected with FEZ Domino.
As I don't have oscilloscope, I could not narrow down the issue. Is there any advice for more investigation?
Test environments:
- Firmware: 4.1.0.3
- Host PC OS: Windows 7
- Change clock rate lower/higher than 1000Khz
- Change SPI mode to 3 (Clock_IdleState = true, Clock_Edge = false)
- Specify ChipSelect_Port in "SPI.Configuration". AS this resulted NG even with FEZ Domino, it seems AT45DB161D require CS active during command send and result acquisition period
- Insert wait (1ms) between CS active and start transaction
- Change jumper wire of SCK
- Power supply from external power jack
using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.Netduino; /* ------------------------------------------- * Pin assignment Netduino <--> AT45DB161D * CS D8 -- 4 Pull-up with 10k ohm R * RESET D9 -- 3 Pull-down with 10k ohm R * MOSI D11 -- 1 * MISO D12 -- 8 * SCK D13 -- 2 --------------------------------------------*/ namespace NetSpiFlash { public class Program { public static void Main() { OutputPort csPin = new OutputPort(Pins.GPIO_PIN_D8, true); OutputPort resetPin = new OutputPort(Pins.GPIO_PIN_D9, true); SPI.Configuration config = new SPI.Configuration( Cpu.Pin.GPIO_NONE, // ChipSelect_Port. Not connected to the device false, // ChipSelect_ActiveState : active low 0, // ChipSelect_SetupTime 0, // ChipSelect_HoldTime false, // Clock_IdleState : the idle state of the clock is low true, // Data is sampled on the SPI clock riging edge (Mode 0) 1000, // Clock_Rate in KHz SPI.SPI_module.SPI1 // SPI_mod : D11 MOSI, D12 MISO, D13 SCK ); SPI spi1 = new SPI(config); AT45DB161D SpiFlash = new AT45DB161D(spi1, csPin, resetPin); byte status; while (true) { status = SpiFlash.ReadStatusRegister(); Debug.Print("Status Reg:" + status.ToString()); SpiFlash.ReadManufacturerAndDeviceID(); Debug.Print("Manufacturer ID:" + SpiFlash.Manufacturer.ToString()); Debug.Print("Device ID:" + SpiFlash.Device[0].ToString()); Thread.Sleep(1000); } } } public class AT45DB161D { // AT45DB161D_Commands private const byte STATUS_REGISTER_READ = 0xD7; private const byte READ_MANUFACTURER_AND_DEVICE_ID = 0x9F; // Chip Select value private const bool CS_INACTIVE = true; private const bool CS_ACTIVE = false; // SPI read/write data private byte[] writeBuffer = new byte[1]; private byte[] readBuffer = new byte[1]; private byte[] dummy = { 0 }; // Device ID feild public byte Manufacturer; public byte[] Device = new byte[2]; public byte ExtendedInfoLength; private SPI spi; private OutputPort cs; /// <summary> /// Constructor for Atmel AT45DB161D data flash /// </summary> public AT45DB161D(SPI spiMod, OutputPort csPin, OutputPort resetPin) { spi = spiMod; cs = csPin; cs.Write(CS_INACTIVE); // Reset AT45DB161D chip resetPin.Write(false); Thread.Sleep(10); resetPin.Write(true); } public byte ReadStatusRegister() { cs.Write(CS_ACTIVE); //Thread.Sleep(1); // Send status read command SPIWriteByte(STATUS_REGISTER_READ); byte status = SPIReadByte(); cs.Write(CS_INACTIVE); return status; } public void ReadManufacturerAndDeviceID() { cs.Write(CS_ACTIVE); //Thread.Sleep(1); // Send status read command SPIWriteByte(READ_MANUFACTURER_AND_DEVICE_ID); // Read Manufacturer ID (1FH, 31) Manufacturer = SPIReadByte(); // Read Device ID (Part 1) (26H, 38) Device[0] = SPIReadByte(); // Read Device ID (Part 2) (00H) Device[1] = SPIReadByte(); // Read Extended Device Information String Length (00H) ExtendedInfoLength = SPIReadByte(); cs.Write(CS_INACTIVE); } private void SPIWriteByte(byte B) { writeBuffer[0] = b; spi.Write(writeBuffer); } private byte SPIReadByte() { spi.WriteRead(dummy, readBuffer); return readBuffer[0]; } } }
#1468 Sparkfun LCD
Posted by todotani on 28 August 2010 - 11:40 AM in Netduino 2 (and Netduino 1)
Ok,
I matched the code from the link EdO referenced to the bus connections shown in the Electronic Bricks Bus documentation. I ended up with this:
LCD_RS = new OutputPort(Pins.GPIO_PIN_D10,false);
LCD_E = new OutputPort(Pins.GPIO_PIN_D12,false);
LCD_D4 = new OutputPort(Pins.GPIO_PIN_D13, false);
LCD_D5 = new OutputPort(Pins.GPIO_PIN_A0, false);
LCD_D6 = new OutputPort(Pins.GPIO_PIN_A1, false);
LCD_D7 = new OutputPort(Pins.GPIO_PIN_A2, false);
When I try the following code:
LCD.Initialize();
while (true)
{
LCD.Print("Hello World");
Thread.Sleep(2000);
LCD.SetCursor(1, 0);
LCD.Print("Hello Netduino");
Thread.Sleep(2000);
LCD.Clear();
Thread.Sleep(2000);
}
I get no response from the LCD. The first row of characters on the LCD is filled with solid blocks, as in the pic attached to the original posting.
Any ideas on how to debug?
As EdO mentioned, R/W pin should be grounded. To do this, try to add the following code;
LCD_RW = new OutputPort(Pins.GPIO_PIN_D11,false);
This feed LCD R/W (pin 11) Low.
- Netduino Forums
- → todotani's Content
- Privacy Policy