Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.
clock.jpg

The data output and signal from SEN

SPI write single byte.PNG

- - - Updated - - -

The output signal of Dout
Standard Signal.jpg
 

These are the signals when I transfer 0x0070 (0x0070 0x0070 | 0x0000) with an address (0x0070) , Mode (write = 0x0000) and 0xff for a data.
get da.jpg
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);
        }
}
Read_Mode.PNG

- - - 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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top