chipKIT® Development Platform

Inspired by Arduino™

Conflict INT and I2C on MAX32

Created Tue, 09 Apr 2013 19:56:32 +0000 by PICedh


PICedh

Tue, 09 Apr 2013 19:56:32 +0000

Hello.

I used to work with UNO since a long time and I was able to use I2c AND 4 external interrupts. I was very sad to discover that on MAX32, 2 external interrupts are lost if you use I2c. Is there any solution ? Can we use other pins for I2c, I see SDA2/SCL2 pins ?

I need 2 interrupts fro 2 wheel encoders and one more fore the WIFI shield

In addition, please note this error in the MAX32 reference document page 10: The CAN2 interface uses the following pins: Pin 23 (AC2RX), Pin 21 (AC2TX).

>>>>it is not pin 21 but pin 22

And also, the pin related to the MAX32 connection described in the WIFI shield reference document are wrong


majenko

Tue, 09 Apr 2013 20:14:31 +0000

You have a huge number of Change Notification pins that can be used like interrupts (see [url]http://sourceforge.net/projects/chipkitcn/[/url]). These aren't quite as responsive as proper interrupt pins, but are still much better than polling.

Also, the pic32mc795f512l chip has something like 5 I²C channels - check the DTWI library.


PICedh

Thu, 11 Apr 2013 19:10:20 +0000

Thanks for your answer, I will use the change notification functionnality to manage interrupt on MAX32 but I still not understand why this board has been designed with this issue.

I known that the PIC has 5 * I2c but I didn't found the DTWI library. so maybe I will code myself

Thanks again four your answer


majenko

Thu, 11 Apr 2013 19:19:24 +0000

A simpler way might be to create your own board variant which takes the current MAX32 as a basis but maps different physical I²C ports instead.

hardware/pic32/variants/Max32/Board_Defs.h:

/* ------------------------------------------------------------ */
/*                  I2C Port Declarations                       */
/* ------------------------------------------------------------ */

/* The standard I2C port uses I2C1 (SCL1/SDA1). These come to digital
** pins 20 & 21 on the communications connector (J4)
*/
#define _TWI_BASE       _I2C1_BASE_ADDRESS
#define _TWI_BUS_IRQ    _I2C1_BUS_IRQ
#define _TWI_SLV_IRQ    _I2C1_SLAVE_IRQ
#define _TWI_MST_IRQ    _I2C1_MASTER_IRQ
#define _TWI_VECTOR     _I2C_1_VECTOR
#define _TWI_IPL_ISR    _I2C1_IPL_ISR
#define _TWI_IPL        _I2C1_IPL_IPC
#define _TWI_SPL        _I2C1_SPL_IPC

Change all those I2C1 entries to I2C4 or whatever you want to use.


PICedh

Thu, 11 Apr 2013 19:27:01 +0000

great idea! I will try ! thanks