PIC32. Problems with I2C.

Post Reply
uwlu
Posts: 2
Joined: Sun Jan 24, 2010 6:35 pm

PIC32. Problems with I2C.

Post by uwlu » Sun Jan 24, 2010 7:37 pm

My hard- and software: PIC32MX360F512L 80MHz, matlab 2008a.

Hi Lubin,
I'm trying to communicate with a HMC5843 sensor. It's a I2C device. For this task I have built a very simple model. I want to use I2C 1 with 400 kHz. The reload value for the BRG can be calculated or taken from the table according the PIC32MX Family Reference Manual, Section 24(DS61116D) p.32. I take the I2CxBRG value for 40 MHz PBCLK from the table 24-1. It is 0x030 or 48 in decimal. I put then this value into the I2C Master Block and get Fscl = 661.157 kHz. Why? Shouldn't be a value about 400 kHz? It's my first problem. The next problem occurs if I try to compilate the model. I get an error message like:
Error using ==> genMakefileAndBuild at 1138

and in Command Window

magnet_field_sensor.c: In function `magnet_field_sensor_step':
magnet_field_sensor.c:48: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:55: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:58: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:67: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:70: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:79: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:82: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:91: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:94: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:104: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:111: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:114: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:124: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:127: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:134: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:137: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:148: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:151: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:170: error: union has no member named `MI2C1IF'
magnet_field_sensor.c:173: error: union has no member named `MI2C1IF'
gmake: *** [magnet_field_sensor.o] Error 1

Could you please give me an advise what I'm doing wrong?

Regards
Oliver
Attachments
magnet_field_sensor.mdl
(27.31 KiB) Downloaded 176 times

uwlu
Posts: 2
Joined: Sun Jan 24, 2010 6:35 pm

Re: PIC32. Problems with I2C.

Post by uwlu » Tue Jan 26, 2010 3:31 pm

Hi Lubin,
Did you overlook my post? I'm still waiting for your help.

Regards
Oliver

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: PIC32. Problems with I2C.

Post by Bobes » Tue Jan 26, 2010 11:02 pm

I dont think I can help you, but you should probably also post your c-file.
Kind regards Josef

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: PIC32. Problems with I2C.

Post by LubinKerhuel » Wed Jan 27, 2010 1:32 am

Hi Olivier,

I should do some more test on I2C with PIC32. I have no project using this target yet and errors may remains.
I'll try to have a look on it, but I may not be able to do it in the next two or three weeks.

Lubin

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest