lpcxpresso 1769 eeprom

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

lpcxpresso 1769 eeprom

1,999件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Sun Jul 22 12:17:39 MST 2012
Hi,

I'm trying to access my onboard epprom, to store some config data on it.
It's a MC24LC64 eeprom. It's connected to P0[19](SDA) and P0[20](SCL) pina on the processor. So I think it's I2C1 - accoring to the manual (LPC1769_68_67_66_65_64_63.pdf)

I know Rob has written a driver and it works, but I'm trying to use CMSIS1.3 as I already have it in my project.

I can't make it work. I don't get any errors but I can't read any data back.
This is what I do:
        // the address is 1010 + 3 address bits A0,A1,A2 (eeprom doc), 
        // which are soldered to ground on lpc1769, so 1010000 -> 0x50
        #define MC24LC64_ADDR 0x50 /* I2C address of the 24LC64 EEPROM */

// setup pins for i2c
PinCfg.OpenDrain = 1;
PinCfg.Pinmode = 0;
PinCfg.Funcnum = 2;
PinCfg.Pinnum = 19;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum = 20;
PINSEL_ConfigPin(&PinCfg);
// Initialize Slave I2C peripheral
I2C_Init(LPC_I2C1, 120000);
/* Enable Slave I2C operation */
I2C_Cmd(LPC_I2C1, ENABLE);

        // 0x00 offset of the memory to write / read
        // 0xfc - some random data to write and read back
uint8_t Buf8[4] = {0x00, 0xfc}; 
uint8_t Recv[8] = {0,0,0,0,0,0,0,0};

transferMCfg.sl_addr7bit = MC24LC64_ADDR;
transferMCfg.tx_data = Buf8;
transferMCfg.tx_length = 2;
transferMCfg.rx_data = NULL;
transferMCfg.rx_length = 0;
transferMCfg.retransmissions_max = 3;
I2C_MasterTransferData(LPC_I2C1, &transferMCfg, I2C_TRANSFER_POLLING);

transferMCfg.sl_addr7bit = MC24LC64_ADDR;
transferMCfg.tx_data = Buf8;
transferMCfg.tx_length = 1;
transferMCfg.rx_data = Recv;
transferMCfg.rx_length = 1;
transferMCfg.retransmissions_max = 3;
I2C_MasterTransferData(LPC_I2C1, &transferMCfg, I2C_TRANSFER_POLLING);


Now every time I run this code I get Recv[0] = 0.
Please help me understand what I'm doing wrong. Thanks.
0 件の賞賛
返信
10 返答(返信)

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 23:25:11 MST 2012
Ah, Found it!
For those who also might be looking: UM10360.pdf,
8.5.2. Pin Function Select Register 1 (PINSEL1 - 0x4002 C004) - page 107

Now the thread is complete :)

Thanks & C'ya
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cmcquaid on Mon Jul 23 16:12:13 MST 2012
UM10360
LPC17xx User manual
Rev. 2 — 19 August 2010

Page 108.

8.5.2 Pin Function Select Register 1 (PINSEL1 - 0x4002 C004)



I'd post the relevant table but it doesn't paste nice.

-- Conor
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 13:54:39 MST 2012
Ok. I've got it. The address is 16bit, not 8bit.
I should trasmit 2 address bytes when reading.

Anyways, please tell me where can I find the information about funcum.
In the LPC1769_68_67_66_65_64_63.pdf there are 3 functions listed by P0[19] and P0[20]. I thought the functions would be indexed from 0, so I2C1 would be 2.
For I2C0 (in my other project) I use pins 27 and 28 and funcum 1 and it works. In pdf (page 11) the function SDA0 is the middle one (from 3 - P0[27]/SDA0/USB_SDA)... So my theory is incosistent :)
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 13:29:47 MST 2012
Wow, thanks. It's almost working now :)
I added a small delay between write and read and now both functions return with success, however the Rcv is filled with 0xff and it should be filled with { 0xfc, 0xfd, 0xfe, 0xff }
Any ideas?

edit: changing the contents of Snd to something else, like { 0x00, 0xaa, 0xbb, 0xcc, 0xdd } doesn't make a difference.
edit2: where can I find this info that funcnum 2 is "reserved"?
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cmcquaid on Mon Jul 23 12:56:43 MST 2012
P0.19 and P0.20 are set to reserved rather than SCL/SDA.

PinCfg.Funcnum = 2;


should be

PinCfg.Funcnum = 3;


That fixes the write...


The read will fail unless you put in a delay to allow the write to complete...

HTH
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 11:31:16 MST 2012
Ok. Attached you will find the zip file containing a simple project, that doesn't work :) Help me find out why, please.
I used the CMSIS1.3 example project pca8581_polling as reference (also attached).

cheers!
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 08:12:54 MST 2012
Hi Angelo,

I know it's based on Robs work - I have it and I've tested it - it works. I just want to use the cmsis driver :)

ps: how's your TC? You never told me if my code worked ok for you.
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Mon Jul 23 04:54:03 MST 2012
Hi Drag,

Look at the examples I sent you weeks (month) ago. :D  The IMU offset data are stored in the on-board eeprom. I used Rob65 I2C driver.

Angelo
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Jul 23 02:06:43 MST 2012
Ok. I will do so in the evening, thanks!
0 件の賞賛
返信

1,897件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Sun Jul 22 14:38:24 MST 2012
Do you shift the address 0x50 one position to the left? :confused:
How do you set the read/write bit? If you just use an AND or OR to set or reset the read/write bit then you shoudl use 0xA0 as address.
We need to see more of the code to be able too give you an answer and to help you. ;)
So please export your project to a zip file and post it here.

Regards,

Serge
0 件の賞賛
返信