FM25V05 read data problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LONGNIGHT
Level 1
Level 1
5 sign-ins First reply posted First question asked

I met a problem that I could detect signal output on the SDO pin of PIC microcontroller with oscilloscope, but the SO pin of FM25V05 did not reply to the data. When the SDO pin of PIC microcontroller or the SI pin of FM25V05 was touched by the conductor, the SO pin of FM25V05 would have data transmitted.

I have also checked that the soldering reliability is okay, on several boards, how can I fix this problem

So that's my code

/******************************************
WriteSPI 写单字节缓冲储存器
*******************************************/
void  WriteSPI(unsigned char i)
    {
    SSP1IF=0;          // clear SSP interrupt bit                   
    SSP1BUF=i;                            
    while(!SSP1IF);    // Wait for interrupt flag to go high indicating transmission is complete  
    return;
    }

/******************************************
** SPI_Write
*******************************************/
void Write_SPI_Byte(uchar n,ucharwr_data_p)       //写全部就定义0xffff
{  
    unsigned char  *fm_addr_p;
    uchar HI,LO;
    SPI_CS=0;
    WriteSPI(0x06);             //写入使能wren指令
    SPI_CS=1;
    __delay_us(10);
    SPI_CS=0;
    WriteSPI(0x02);             //写储存器
    fm_addr_p=(uchar*)&fm_addr;
    LO=*fm_addr_p;
    fm_addr_p++;
    HI=*fm_addr_p;  
    WriteSPI(HI);               //先写存储器地址高字节
    WriteSPI(LO);               //写存储器地址低字节      
    while(n--)
    {
    WriteSPI(*wr_data_p);       //写数据
    wr_data_p++;
    fm_addr++;
    }
    SPI_CS=1;                        //停止从机 
}

//**************************************************************************************
// ReadSPI 读单字节缓冲
//**************************************************************************************
unsigned char ReadSPI()
    {
    unsigned char databyte;
    SSP1IF=0;                    // Clear SSP interrupt bit
    SSP1BUF = 0x00;              // Write dummy data byte to the buffer to initiate transmission
    while(!SSP1IF);                 // Wait for interrupt flag to go high indicating transmission is complete
    databyte = SSP1BUF;          // Read the incoming data byte
    return (databyte);
    }
/******************************************
SPI_Read
*******************************************/

unsigned char Read_SPI_Byte()// 从储存器里读一个字节
  {
    uchar *fm_addr_p;               //定义地址指针
    uchar HI,LO;                    //定义写入地址
    uchar data_read;                //字节
    SSP1IF=0;
    SPI_CS=0;
    WriteSPI(0x03);                   //写读储存器命令
   
    fm_addr_p=(uchar*)&fm_addr;
    LO=*fm_addr_p;
    fm_addr_p++;
    HI=*fm_addr_p;
    WriteSPI(HI);             
    WriteSPI(LO);                        //写高低位地址         
    WriteSPI(0xff);                      //启动读数            
    data_read = ReadSPI();                  //输出数据
    fm_addr++;
    SPI_CS=1;
    return(data_read);
   }
0 Likes
4 Replies