This might be a bit off topic since its probably a more atmel chip problem, but I try here anyways. Im using a flash memory chip together with the MSP430F1121A chip. Im wondering if somebody out there has done the same, cause I seem to have a problem reading from the flash memory or programming the flash. I can read and write to and from its rambuffer. But when it comes to either the flashing or reading of data from flash I can't make it work. Jardar
F1121 with AT45DB011B flash from ATMEL
Started by ●January 23, 2003
Reply by ●January 23, 20032003-01-23
Hello Jardar, Actually I experienced that same problem too, but I was interfacing the chip to the ATmega128. Are you sure you are giving the chip enough time to access the flash? Programming the flash can take up to 14ms. So always check the Ready/Busy flag for the state of the flash. That's all I can say for now without seeing any code. Also, I have some c code directly from Atmel, that covers most of the functions the chip does, let me know if you would like me to send it to you. Later, Matt Sabino ----- Original Message ----- From: Jardar Johannes Maatje To: msp430@msp4... Sent: Thursday, January 23, 2003 12:33 PM Subject: [msp430] F1121 with AT45DB011B flash from ATMEL This might be a bit off topic since its probably a more atmel chip problem, but I try here anyways. Im using a flash memory chip together with the MSP430F1121A chip. Im wondering if somebody out there has done the same, cause I seem to have a problem reading from the flash memory or programming the flash. I can read and write to and from its rambuffer. But when it comes to either the flashing or reading of data from flash I can't make it work. Jardar .
Reply by ●January 23, 20032003-01-23
Have you made sure you are sending the 32 "don't care" bits (1) with the proper command sequence to the DataFlash ? 2 people I helped out in the past with the same problem overlooked sending the proper command with the extra bits (for the state machine in the Flash chip). Cheers Kris Hello Jardar, Actually I experienced that same problem too, but I was interfacing the chip to the ATmega128. Are you sure you are giving the chip enough time to access the flash? Programming the flash can take up to 14ms. So always check the Ready/Busy flag for the state of the flash. That's all I can say for now without seeing any code. Also, I have some c code directly from Atmel, that covers most of the functions the chip does, let me know if you would like me to send it to you. Later, Matt Sabino
Reply by ●January 24, 20032003-01-24
Funny thing - I've been struggling with a similar problem for a few days now. My setup: MSP430F149 clocking at 1.8432Mhz connected to AT45DB011B using SPI port 0, I'm initing the SPI with the code below: I'm not absolutely sure, but I believe I'm operating in SPI Mode 3 as diagrammed in the AT45DB011B datasheet. Things that work for me: 1) I can read status register and RDY/BUSY bit - reads 0x86 when not busy. 2) In a tight loop I can read and write the dataFlash buffer (see test code) What doesn't work for me: 1) reading and writing dataFlash buffer when called from normal program flow (response to UART1 serial port protocol for writing and reading data records). I write numbers 0 to 255 in locations 0 to 255 and always read back 0's in normal program flow. In my test loop, I read back what is written. I haven't tried programming flash memory yet, not until I get a handle on reading and writing Buf1. I've included the code below as a sample for those that haven't made it as far as I have, and also as a plea for someone who knows the subtleties of the part to perhaps spot the problem. Thom spi_init() { ME1 |= USPIE0; // ME1.6 (USPIE0=URXE0) enable tx/rx in SPI mode UTCTL0 = CKPL+SSEL1+SSEL0+STC; // WORKS: (reads 0x86) (SPI Mode 3 I believe) UCTL0 = CHAR+SYNC+MM+SWRST; // 8bit SPI Master **SWRST** UBR00 = 0x02; // UCLK/2 UBR10 = 0x00; // 0 UMCTL0 = 0x00; // no modulation P3SEL |= 0x0E; // P3.1,2,3 SPI option select P3.1=SIMO, P3.2=SOMI, P3.3=UCLK0 P3DIR |= 0x0B; // P3.0(unused)=1, P3.1(SIMO)=1, P3.2(SOMI)=0, P3.3(UCLK)=1 P4SEL &= 0xDF; // P4.5 SEL=0, Port function, out CS_FLASH P4DIR |= 0x20; // P4.5 DIR=1 output direction P4OUT |= 0x20; // Write P4.5 outbit CS=1 UCTL0 &= 0xfe; // reset bit.0=SWRST } while(1) { for(indx=0; indx<256; indx++) { tx.buf[indx] = indx; rx.buf[indx] = 0xff; } flash_writeBuf1(&tx.buf[0], 0, 256); // adjustable delay to see if it's the delay that's causing the failure // the delay (even up to 10 sec) seems to have no bearing on writing then reading the data as verified by the output to Hyperterminal led_red_on(); for(big=0L; big<1000000L; big++); led_red_off(); flash_readBuf1(&rx.buf[0], 0, 256); for(indx=0; indx<250; indx++) { uart_writeByte(rx.buf[indx]); } led_green_toggle(); } /* * Routine: spi_readByte * * Description: read a byte from serial dataflash on SPI port, assumes caller * has dropped the chip select line (and for now has written * a dummy byte to gen the clock for the read - will look at putting * this dummy write into the read routine). * * Inputs: None * Returns: the byte read from SPI port */ Byte spi_readByte(void) { return(RXBUF0); } /* * Routine: spi_writeByte * * Description: write a byte to the serial dataflash on SPI port, assumes caller * is managing the chip select line. * * Inputs: byte to write * Returns: nothing */ void spi_writeByte(Byte wrByte) { while ((IFG1 & UTXIFG0) == 0); // USART0 TX buffer ready? TXBUF0 = wrByte; } /* * Routine: flash_readStatusReg * * Description: * * * Inputs: * Returns: status register from AT45DB011B / AT45DB021B */ Byte flash_readStatusReg(void) { Byte rxVal; spi_chipSel_LO(); spi_writeByte(DATA_FLASH_STATUS); // 0x57 spi_writeByte(DUMMY_WRITE); // Dummy write to clock the data in 0x00 rxVal = spi_readByte(); spi_chipSel_HI(); return(rxVal); } /* * Routine: flash_writeBuf1 * * Description: write into buffer1 * * * Inputs: ptr to data buf, addr, cnt (264 max for each) * Returns: */ void flash_writeBuf1(Byte *srcPtr, Uint16 addr, Uint16 cnt) { Uint16 indx; addr &= 0x1ff; cnt &= 0x1ff; // spi_chipSel_LO(); spi_writeByte(BUFFER1_WRITE); // Buffer1 Write 0x84 spi_writeByte(0x00); spi_writeByte((Byte) (addr/256)); spi_writeByte((Byte) addr); for(indx=0; indx<cnt; indx++) { spi_writeByte(*srcPtr++); } spi_chipSel_HI(); } /* * Routine: flash_readBuf1 * * Description: read from buffer1 * * * Inputs: ptr to data buf, addr, cnt (264 max for each) * Returns: */ void flash_readBuf1(Byte *dstPtr, Uint16 addr, Uint16 cnt) { Uint16 indx; addr &= 0x1ff; cnt &= 0x1ff; // spi_chipSel_LO(); spi_writeByte(BUFFER1_READ); // Buffer1 Read 0x84 spi_writeByte(0x00); spi_writeByte((Byte) (addr/256)); spi_writeByte((Byte) addr); // spi_writeByte(DUMMY_WRITE); // not sure? for(indx=0; indx<cnt; indx++) { spi_writeByte(DUMMY_WRITE); *dstPtr = spi_readByte(); dstPtr++; } spi_chipSel_HI(); } ----- Original Message ----- From: "microbit" <microbit@micr...> To: <msp430@msp4...> Sent: Thursday, January 23, 2003 12:42 PM Subject: Re: [msp430] F1121 with AT45DB011B flash from ATMEL > Have you made sure you are sending the 32 "don't care" bits (1) with the > proper command sequence to the DataFlash ? > 2 people I helped out in the past with the same problem overlooked sending > the proper command with the extra > bits (for the state machine in the Flash chip). > > Cheers > Kris > > > Hello Jardar, > Actually I experienced that same problem too, but I was interfacing the > chip to the ATmega128. Are you sure you are giving the chip enough time to > access the flash? Programming the flash can take up to 14ms. So always > check the Ready/Busy flag for the state of the flash. That's all I can say > for now without seeing any code. Also, I have some c code directly from > Atmel, that covers most of the functions the chip does, let me know if you > would like me to send it to you. > > Later, > > Matt Sabino > > > . > > > > ">http://docs.yahoo.com/info/terms/ > >