|
|
View previous topic :: View next topic |
Author |
Message |
AJ Guest
|
pic18->m25p54 |
Posted: Mon Jun 27, 2005 8:12 am |
|
|
Hello,
I have been trying to connect a PIC18F452 at 20Mhz to the M25P64(Memory Chip from ST Microelectronics). I have read the previous forum posts, but i had no luck in establishing a connection. I tried both the hardware SPI using built-in functions and also software implemention. I can see with the help of an oscilloscope, the train of pulses going, but the SDO pin of the M25P64 always remains low. I have tried putting delays and using various speeds. Even if i run the program like
while (TRUE){
output_low(flash_select);
printf("%X",spi_read(0x9f));
delay_ms(1000);
output_high(flash_select);
}
still can see only the pulses going out through the SDO pin of the PIC. But nothing is seen on the SDO pin of the M25P64. I am using voltage-dividers for level converting and also tried using the LF version of the PIC.
Then I tried the software one as shown below:
void send_byte_flash(int8 data){
int i;
output_low(FLASH_SEL);
delay_ms(1);
output_low(FLASH_SCK);
for(i=0; i<8; ++i)
{
output_bit(FLASH_DI, shift_left(&data,1,0)); // Send a data bit
output_high(FLASH_SCK);
delay_ms(1); // Pulse the clock
output_low(FLASH_SCK);
}
output_high(FLASH_SEL);
}
//.............................................................................................................
BYTE get_byte_flash()
{int i;
BYTE flashData;
output_low(FLASH_SEL);
delay_ms(1);
output_high(FLASH_SCK);
for(i=0; i<8; ++i) // Get 8 bits of data
{ output_low(FLASH_SCK);
shift_left(&flashData, 1, input(FLASH_DO));
delay_ms(1);
output_high(FLASH_SCK);
}
output_high(FLASH_SEL);
return flashData;
}
//.................................................................................................................
BYTE read_id_flash()
{
BYTE status;
output_low(FLASH_SEL); // Enable select line
send_byte_flash(0x9f); // Send status command
status = get_byte_flash(); // Get the status
output_high(FLASH_SEL); // Disable select line
return status; // Return the status
}
But none of this worked.
Your help will be very much appreciated.Thanks. |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 27, 2005 8:29 am |
|
|
Looking at the data sheet, you need to clock three more transactions after sending the 'read identification' command. Basically, when you send this command, the chip then responds _on the next transaction_, with the first identification byte. So your test code would need to be something like:
Code: |
while (TRUE){
output_low(flash_select);
spi_write(0x9F);
printf("%2X,%2X,%2X/n",spi_read(),spi_read(),spi_read());
output_high(flash_select);
delay_ms(1000);
}
|
The chip does not respond to the command transaction (if you think about it, it can't - it does not know what the command 'is', till the transaction is finished).
Best Wishes |
|
|
AJ Guest
|
PIC18F452->M25P64 |
Posted: Mon Jun 27, 2005 8:23 pm |
|
|
Hello,
I really appreciate your help. But I'm sorry that the problem is not that simple.
I have tested all modes of built-in SPI functions in all modes.
I have used the modes like SPI_MASTER, SPI_SS_DISABLED, SPI_XMIT_L_TO_H, SPI_L_TO_HIGH, SPI_CLK_DIV_4, SPI_CLK_DIV_64, SPI_CLK_DIV_16, SPI_SAMPLE_AT_END. But no effect. I also tried the pull-up resistors on SDI,SDO,SCK outputs. but still the SDO_pin of the M25P64 is always low no matter what.
I tried using the sotware SPI using differnt delays for read and write operation. (I studied the SPI drivers supplied by the CCS and did something similar.) . Still the same.
I am not ruling out the possibility that the chip is not working. But the chances are very less, since i have changed a couple of units to test. Do you know of a way to test whether the chip is alright or not (other than the read_identification. something electrical) ? It's been quite a few days for me now. I have got other memory chips which use I2C working without any hiccups.
I know there must be some aspect of the M25P64 or the PIC's SPI that I don't take into consideration which may be the key to this. I need some more help.
|
|
|
AJ Guest
|
PIC18F452->M25P64 |
Posted: Mon Jun 27, 2005 8:24 pm |
|
|
Hello,
I really appreciate your help. But I'm sorry that the problem is not that simple.
I have tested all modes of built-in SPI functions in all modes.
I have used the modes like SPI_MASTER, SPI_SS_DISABLED, SPI_XMIT_L_TO_H, SPI_L_TO_HIGH, SPI_CLK_DIV_4, SPI_CLK_DIV_64, SPI_CLK_DIV_16, SPI_SAMPLE_AT_END. But no effect. I also tried the pull-up resistors on SDI,SDO,SCK outputs. but still the SDO_pin of the M25P64 is always low no matter what.
I tried using the sotware SPI using differnt delays for read and write operation. (I studied the SPI drivers supplied by the CCS and did something similar.) . Still the same.
I am not ruling out the possibility that the chip is not working. But the chances are very less, since i have changed a couple of units to test. Do you know of a way to test whether the chip is alright or not (other than the read_identification. something electrical) ? It's been quite a few days for me now. I have got other memory chips which use I2C working without any hiccups.
I know there must be some aspect of the M25P64 or the PIC's SPI that I don't take into consideration which may be the key to this. I need some more help.
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jun 28, 2005 3:53 am |
|
|
Have you actually tried what I suggested?.
Your manual 'test' code, won't work, because you deselect the chip between bytes. The 'point' is that the chip has to be selected, then clocked a command, and then _while still selected_, the response must be clocked back.
A variant of the test code (actually clocking an address, and reading the byte back), has worked OK for me in the past.
Best Wishes |
|
|
AJ Guest
|
PIC18F452->M25P64 |
Posted: Tue Jun 28, 2005 4:35 am |
|
|
Hello friend,
I have tried what you have said. But that did not help. In fact i had tried this earlier also where it failed.
Regarding the chip-select like what you say, I've just tried not making the chip-select high(Deselecting). But it ain't kicking.
Have you interfaced any serial flash memory modules from ST Microelectronics before ? I am really lost. |
|
|
Ttlemah Guest
|
|
Posted: Tue Jun 28, 2005 5:20 am |
|
|
Yes, I have used the smaller models of the M25P family, in the past, and had no problems.
I did have problems in the past with the CCS SSP functions, ad have in the past posted my own 'variants', which were what I actually used for this. However the newer compiler versions seem to have fixed these oddities.
Best Wishes |
|
|
AJ Guest
|
PIC18F452->M25P64 |
Posted: Tue Jun 28, 2005 5:38 am |
|
|
Hello,
I am using the PCWH compiler version 3.225. I have tried some of the codes found here in this forum before. Is there any setting in the M25P64 that i should make before writing commands to read the ID or write enable. I just can't figure it out. Please Help. |
|
|
Guest
|
Re: pic18->m25p54 |
Posted: Tue Jun 28, 2005 6:18 am |
|
|
AJ wrote: | Hello,
I have been trying to connect a PIC18F452 at 20Mhz to the M25P64(Memory Chip from ST Microelectronics). I have read the previous forum posts, but i had no luck in establishing a connection. I tried both the hardware SPI using built-in functions and also software implemention. I can see with the help of an oscilloscope, the train of pulses going, but the SDO pin of the M25P64 always remains low. I have tried putting delays and using various speeds. Even if i run the program like
while (TRUE){
output_low(flash_select);
printf("%X",spi_read(0x9f));
delay_ms(1000);
output_high(flash_select);
}
still can see only the pulses going out through the SDO pin of the PIC. But nothing is seen on the SDO pin of the M25P64. I am using voltage-dividers for level converting and also tried using the LF version of the PIC.
Then I tried the software one as shown below:
void send_byte_flash(int8 data){
int i;
delay_ms(1);
output_low(FLASH_SCK);
for(i=0; i<8; ++i)
{
output_bit(FLASH_DI, shift_left(&data,1,0)); // Send a data bit
output_high(FLASH_SCK);
delay_ms(1); // Pulse the clock
output_low(FLASH_SCK);
}
}
//........................................................................................................
BYTE get_byte_flash()
{int i;
BYTE flashData;
delay_ms(1);
output_high(FLASH_SCK);
for(i=0; i<8; ++i) // Get 8 bits of data
{ output_low(FLASH_SCK);
shift_left(&flashData, 1, input(FLASH_DO));
delay_ms(1);
}
return flashData;
}
//.................................................................................................................
BYTE read_id_flash()
{
BYTE status;
output_low(FLASH_SEL); // Enable select line
send_byte_flash(0x9f); // Send status command
status = get_byte_flash(); // Get the status
output_high(FLASH_SEL); // Disable select line
return status; // Return the status
}
But none of this worked.
Your help will be very much appreciated.Thanks. |
|
|
|
AJ Guest
|
PIC18F452->M25P64 |
Posted: Tue Jun 28, 2005 11:24 pm |
|
|
Anybody there to help me ?? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|