I am trying to attach an I2C peripheral to my LPCXpresso 824 Max board. The schematic from Embedded Artists shows SDA as PIO0_10, Pin 9 and SCL as PIO0_11, Pin 8 (both pins have pull-up resistors). However, file swm_8xx.h shows SDA as PIO0_11 and SCL as PIO0_12. Furthermore, the comment in one of the I2C example programs describes SDA as P0.10 and SCL as P0_11. Which are the correct ports and pins for I2C0?
Solved! Go to Solution.
Hi Julian,
Thank you for your interest in NXP LPC product, I would like to provide service for you!
1.LPCXpresso 824 Max board schematic I2C pin assignment
From the schematic:
We can get that, I2C0_SCL is PIO10, I2C0_SDA is PIO11.
2. swm_8xx.h I2C defination
From the according lpcopen sample code, swm_8xx.h, we can get the I2C defination
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);
STATIC INLINE void Chip_SWM_EnableFixedPin(CHIP_SWM_PIN_FIXED_T pin)
{
LPC_SWM->PINENABLE0 &= ~((1 << (uint32_t) pin) | SWM_PINENABLE0_RESERVED);
}
#if defined(CHIP_LPC82X)
typedef enum CHIP_SWM_PIN_FIXED {
SWM_FIXED_ACMP_I1 = 0, /*!< ACMP I1 */
SWM_FIXED_ACMP_I2 = 1, /*!< ACMP I2 */
SWM_FIXED_ACMP_I3 = 2, /*!< ACMP I3 */
SWM_FIXED_ACMP_I4 = 3, /*!< ACMP I4 */
SWM_FIXED_SWCLK = 4, /*!< SWCLK */
SWM_FIXED_SWDIO = 5, /*!< SWDIO */
SWM_FIXED_XTALIN = 6, /*!< XTALIN */
SWM_FIXED_XTALOUT = 7, /*!< XTALOUT */
SWM_FIXED_RST = 8, /*!< Reset */
SWM_FIXED_CLKIN = 9, /*!< Clock Input */
SWM_FIXED_VDDCMP = 10, /*!< VDD */
SWM_FIXED_I2C0_SDA = 11, /*!< I2C0 SDA */
SWM_FIXED_I2C0_SCL = 12, /*!< I2C0 SCL */
SWM_FIXED_ADC0 = 13, /*!< ADC0 */
SWM_FIXED_ADC1 = 14, /*!< ADC1 */
SWM_FIXED_ADC2 = 15, /*!< ADC2 */
SWM_FIXED_ADC3 = 16, /*!< ADC3 */
SWM_FIXED_ADC4 = 17, /*!< ADC4 */
SWM_FIXED_ADC5 = 18, /*!< ADC5 */
SWM_FIXED_ADC6 = 19, /*!< ADC6 */
SWM_FIXED_ADC7 = 20, /*!< ADC7 */
SWM_FIXED_ADC8 = 21, /*!< ADC8 */
SWM_FIXED_ADC9 = 22, /*!< ADC9 */
SWM_FIXED_ADC10 = 23, /*!< ADC10 */
SWM_FIXED_ADC11 = 24, /*!< ADC11 */
} CHIP_SWM_PIN_FIXED_T;
From the above code, you can get that, the swm_8xx.h is just define the I2C0 register LPC_SWM->PINENABLE0.
Please refer to user manual, page86, you will find:
SWN_PINENABLE 0[11]: enable I2C0_SDA on pin PIO0_11,
SWN_PINENABLE 0[12]: enable I2C0_SCL pin on PIO0_10,
swm_8xx.h just define the register, 11, 12 is just the PINENABLE0 regiser bit number, not pin number. The pin still PIO0_11,PIO0_10,
So the swm_8xx.h defination has no conflict with the schematic I2C pin assignment.
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Julian,
Thank you for your interest in NXP LPC product, I would like to provide service for you!
1.LPCXpresso 824 Max board schematic I2C pin assignment
From the schematic:
We can get that, I2C0_SCL is PIO10, I2C0_SDA is PIO11.
2. swm_8xx.h I2C defination
From the according lpcopen sample code, swm_8xx.h, we can get the I2C defination
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);
STATIC INLINE void Chip_SWM_EnableFixedPin(CHIP_SWM_PIN_FIXED_T pin)
{
LPC_SWM->PINENABLE0 &= ~((1 << (uint32_t) pin) | SWM_PINENABLE0_RESERVED);
}
#if defined(CHIP_LPC82X)
typedef enum CHIP_SWM_PIN_FIXED {
SWM_FIXED_ACMP_I1 = 0, /*!< ACMP I1 */
SWM_FIXED_ACMP_I2 = 1, /*!< ACMP I2 */
SWM_FIXED_ACMP_I3 = 2, /*!< ACMP I3 */
SWM_FIXED_ACMP_I4 = 3, /*!< ACMP I4 */
SWM_FIXED_SWCLK = 4, /*!< SWCLK */
SWM_FIXED_SWDIO = 5, /*!< SWDIO */
SWM_FIXED_XTALIN = 6, /*!< XTALIN */
SWM_FIXED_XTALOUT = 7, /*!< XTALOUT */
SWM_FIXED_RST = 8, /*!< Reset */
SWM_FIXED_CLKIN = 9, /*!< Clock Input */
SWM_FIXED_VDDCMP = 10, /*!< VDD */
SWM_FIXED_I2C0_SDA = 11, /*!< I2C0 SDA */
SWM_FIXED_I2C0_SCL = 12, /*!< I2C0 SCL */
SWM_FIXED_ADC0 = 13, /*!< ADC0 */
SWM_FIXED_ADC1 = 14, /*!< ADC1 */
SWM_FIXED_ADC2 = 15, /*!< ADC2 */
SWM_FIXED_ADC3 = 16, /*!< ADC3 */
SWM_FIXED_ADC4 = 17, /*!< ADC4 */
SWM_FIXED_ADC5 = 18, /*!< ADC5 */
SWM_FIXED_ADC6 = 19, /*!< ADC6 */
SWM_FIXED_ADC7 = 20, /*!< ADC7 */
SWM_FIXED_ADC8 = 21, /*!< ADC8 */
SWM_FIXED_ADC9 = 22, /*!< ADC9 */
SWM_FIXED_ADC10 = 23, /*!< ADC10 */
SWM_FIXED_ADC11 = 24, /*!< ADC11 */
} CHIP_SWM_PIN_FIXED_T;
From the above code, you can get that, the swm_8xx.h is just define the I2C0 register LPC_SWM->PINENABLE0.
Please refer to user manual, page86, you will find:
SWN_PINENABLE 0[11]: enable I2C0_SDA on pin PIO0_11,
SWN_PINENABLE 0[12]: enable I2C0_SCL pin on PIO0_10,
swm_8xx.h just define the register, 11, 12 is just the PINENABLE0 regiser bit number, not pin number. The pin still PIO0_11,PIO0_10,
So the swm_8xx.h defination has no conflict with the schematic I2C pin assignment.
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
While trying to resolve this problem I examined the LPC824 pin descriptions in the NXP document UM10800 Table 402 on page 409 and it bears very little relation to "typedef enum CHIP_SWM_PIN_Fixed" in file "sim_8xx.h". If this is correct then very few of the fixed pin functions would ever work (which can't be true) !!!!!!!!