|
|
View previous topic :: View next topic |
Author |
Message |
beaker404
Joined: 24 Jul 2012 Posts: 163
|
SPI 16B address and 8b data |
Posted: Mon Aug 15, 2022 12:20 pm |
|
|
CCS 5.064
PIC18F26K22
EEPROM 93LC66C
Looked around the forum and nothing came out as an exact solution to my problem,
problem being, using a 93LC66 in 8b data mode so 512 x 8 bytes.
Communication is via SPI and works find IF I stay below an address of 255
and I know why, the SPI is only sending 8b of address, tried sending MSB and LSB of the address word, did not work.
Is there a way to get a 16b address to the EEPROM followed by the 8b data? Perhaps I just do not get SPI well enough to resolve it.
SPI set up like this: for 8b data, this all works just not when I try to do 16b addressing.
Code: |
#DEFINE SPI_XFER_9356(x) spi_xfer(SPI2_EEPROM, x)
#DEFINE EEPROM_ADDRESS unsigned long
#use spi(master, DO=Pin_B3, CLK=PIN_B1, DI=PIN_B2 ,ENABLE_ACTIVE=1, ENABLE_DELAY=20,mode=0, baud=2000000, stream=SPI2_EEPROM, bits=8, FORCE_SW) |
my write function:
Code: | void write_ext_eeprom(EEPROM_ADDRESS address, BYTE data)
{
disable_interrupts(global);
output_high(EEPROM_SELECT);
SPI_XFER_9356(0xa);
SPI_XFER_9356(address);
SPI_XFER_9356(data);
output_low(EEPROM_SELECT);
delay_ms(11);
enable_interrupts(global);
} |
my read function:
Code: | BYTE read_ext_eeprom(EEPROM_ADDRESS address)
{
BYTE data;
disable_interrupts(global);
output_high(EEPROM_SELECT);
SPI_XFER_9356(0xc);
SPI_XFER_9356(address);
data=SPI_XFER_9356(0);
output_low(EEPROM_SELECT);
enable_interrupts(global);
return(data);
} |
|
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Mon Aug 15, 2022 12:22 pm |
|
|
sorry for the poor formatting of the thread, for some reason I cannot edit it now correctly. |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Mon Aug 15, 2022 12:43 pm |
|
|
To access addresses 256-511, the high address bit is the low bit of the command.
Code: |
output_high(EEPROM_SELECT);
SPI_XFER_9356(0x0c | 0x01); // command and high bit of address
SPI_XFER_9356(address); // low 8 bits of address
data=SPI_XFER_9356(0);
output_low(EEPROM_SELECT);
|
|
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Mon Aug 15, 2022 1:14 pm |
|
|
thanks.
Not sure how I missed that in the datasheet, |
|
|
|
|
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
|