SPI problem in eeprom pic16f151x

Status
Not open for further replies.
All of the signals are ok, now. However I am still not get the expected results. I am trying to write the SPI_Read to get the data back to debug.


The data output and signal from SEN



- - - Updated - - -

The output signal of Dout
 

These are the signals when I transfer 0x0070 (0x0070 0x0070 | 0x0000) with an address (0x0070) , Mode (write = 0x0000) and 0xff for a data.

Does anyone know how to write the read data from MikroC. I want to check base on the MCU. I wrote like that but it is not work.
Code:
unsigned char SL900A_Read(unsigned int uirMode, unsigned int uirAddress){
     unsigned char ucResult;
     SEN = 1;
     delay_us(300);
     uiTemp = uirAddress | uirMode;
     SPI1_Write(uiTemp >> 8);
     SPI1_Write(uirAddress & 0x00FF);
     delay_us(300);
     ucResult= SPI1_Read(0);
     delay_ms(1);
     SEN = 0;
     return ucResult;
}
Code:
unsigned char ucKQ;
unsigned int uiAdd,i,uiMo,uirMo;
ucKQ = SL900A_Read(uirMo, 0x01F0);
while(1){
if(ucKQ == 0x01)
        {
         PORTB.B4 = 1;
        }
     else
        {
        PORTB.B4 = 1;
        delay_ms(500);
        PORTB.B4 = 0;
        delay_ms(500);
        }
}


- - - Updated - - -

I just skip some code lines (SPI_Init) and declare the Internal Clock.
You can see in the attached file. Thanks.
View attachment SL900A.rar
 

I wrote data to EEPROM but the result was not good. Some memory regions were skiped. I think I chose inapproriate delay value.
 

20 ms delay should be used between successive read or write to eeprom. Also GIE_bit has to be turned OFF before eeprom operation and it has to be enabled if needed after eeprom operation.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…