Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

drive FRAMs of Ramtron

drive FRAMs of Ramtron

2005-12-07 by tastingfan tastingfan

Hi,
   
  Does anyone here drive FRAMs of Ramtron? My idea is descreibed as following:
   
  One byte (0xb0) is written into FRAM with the function ‘Write_FRAM_Byte()’, ‘Read_FRAM_Byte()’ reads out this byte and sends it to the UART0 interface (UART0_SendByte()). But this program does not work at all, that is, there is no output to the UART0. I don’t know whether the problem is related to the write process or the read process. I am using LPC2131 and FM25CL64 of FRAM.
   
  Thank you
  Xia Shang
   
  #include "config.h"
   
  #define FM25L64_CS  (1 << 29)  //P0.29 is Chip Select port
  #define ADDRESS_START     0x0123     // address of FRAM
  #define  WREN                                0x06       // command of FRAM
  #define    WRITE                      0x02       // command of FRAM
  #define  READ                                 0x03       // command of FRAM
  #define WRITE_ENABLE   MSPI_SendData(WREN)
  #define WRITE_DATA     MSPI_SendData(WRITE)
  #define READ_DATA      MSPI_SendData(READ)
  #define    UART_BPS     9600                            // baudrate of the UART
   
  // initializing the SPI
  void  MSPI_Init(void)
  {  
         SPCCR = 0x52;                        // clock divider of SPI
        SPCR  = (1 << 3) |                           // CPHA = 1
                                    (1 << 4) |                            // CPOL = 1
                                    (1 << 5) |                            // MSTR = 1
                                    (0 << 6) |                            // LSBF = 0
                                    (0 << 7);                             // SPIE = 0
  }
   
  // send process of SPI
  void MSPI_SendData(uint8 data)
  {
    SPDR = data;
    while( 0 == (SPSR & 0x80));          // wait for SPIF until the data is finished
  }
   
  // write process of SPI
  void Write_FRAM_Byte(uint16 address,uint8 data_write)
  {
         IO0CLR = FM25L64_CS;  //select FM25CL64
         WRITE_ENABLE;         // WREN
         WRITE_DATA;             // WRITE
         MSPI_SendData((uint8)(address>>8));   // high address
         MSPI_SendData((uint8)address);         // low address
         MSPI_SendData(data_write);              // data     
         IO0SET = FM25L64_CS;
  }     
   
   
   
  uint8 MSPI_ReadData()
  {
         uint8 temp,status;
         while(0 == (SPSR & 0x80));
         status = SPSR;
         temp = SPDR;
         return(temp);
  }
   
  // read process of SPI
  uint8 Read_FRAM_Byte(uint16 address)
  {
         uint8 data_temp;
         IO0CLR = FM25L64_CS;
         READ_DATA; // send 'READ'�R
         MSPI_SendData((uint8)(address>>8));
         MSPI_SendData((uint8)address);
         data_temp = MSPI_ReadData();
         IO0SET = FM25L64_CS;
         return(data_temp);
  }
   
  void UART0_Init (void)
  {
         uint16 Fdiv;
         
         U0LCR = 0x83;                                         // DLAB=1
         Fdiv  = (Fpclk / 16) / UART_BPS;      // setting the baudrate
         U0DLM = Fdiv / 256;
         U0DLL = Fdiv % 256;
         U0LCR = 0x03;
  }
   
  void UART0_SendByte (uint8 dat)
  {
         U0THR = dat;
         while ((U0LSR & 0x40) == 0);            // waiting, until data is finished
  }
   
  int main (void)
  {
         uint8 i, temp;
         PINSEL0 = 0x00005505;                                    // selecting SPI and UART0
        PINSEL1 = 0x00000000;
        IO0DIR = FM25L64_CS;
     
        MSPI_Init();                                               
      UART0_Init();
      
      while(1)
      {
              Write_FRAM_Byte(ADDRESS_START,0xb0);           
             temp = Read_FRAM_Byte(ADDRESS_START);
               UART0_SendByte(temp);
        }
        return 0;
  }
   


__________________________________________________
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com

[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.