Motor Control

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Motor Control

421 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sat Sep 29 12:06:14 MST 2012
Hi

I have the motor control kit form Embedded Artists and I would like to use with LPC1768 however I am having difficulty to work with OLED display, anyone have any ideas?, at the schematic the OLED I2C pins is P0.10(SDA) and P0.11(SCL) I'm trying to use I2C2 interface  but does not work, my OLED code is the sample code provide with the motor kit (lpc1114), I just make some alterations to accept the I2C2 interface.

please someone can help me.

Regards,
hcanova
0 Kudos
6 Replies

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel.widyanto on Thu Oct 04 01:43:55 MST 2012
Hi,

If you use open drain, then pull up resistor must be connected to the pins. Otherwise, the bus will never reach HIGH state.

My suggestion is try to send the START bit (LPC_I2C2->CONSET |= CONSET_STA) and check the signals at the SCL2 and SDA2.
0 Kudos

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sun Sep 30 17:55:34 MST 2012
I read on the Lpc17xx errata about the open drain problem in the GPIO pins,



Quote:

Open drain mode can be selected for every standard general purpose port pin only when configured as a GPIO function



Someone knows if this can be an problem when using the I2C2 port P0.10 and P0.11 with an special function?

Thanks
0 Kudos

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sun Sep 30 17:26:52 MST 2012

Quote: cfb
My guess is that the reference to P0.15 is an error.

Have you initialised the I2C interface for the LPC1769 before calling the functions you attached?

We do this in Oberon with the following code. It should not be too hard to translate to C:

    SYSTEM.PUT(MCU.PCONP, pconp + {26});
   (* Connect I2C2 signals *)
    (* P0.10 = SDA2, PINSEL0:21:20 = 10B *)
    (* P0.11 = SCL2, PINSEL0:23:22 = 10B *)
    SYSTEM.GET(MCU.PINSEL0, s);
    SYSTEM.PUT(MCU.PINSEL0, s - {20, 22} + {21, 23});
    (* no pull-up or pull-down *)
    (* PINMODE0:21:20 = 10B *)
    (* PINMODE0:23:22 = 10B *)
    SYSTEM.GET(MCU.PINMODE0, s);
    SYSTEM.PUT(MCU.PINMODE0, s - {20, 22} + {21, 23});
    SYSTEM.GET(MCU.PINMODE_OD0, s);
    SYSTEM.PUT(MCU.PINMODE_OD0, s + {10, 11})

If you are not familiar with Oberon code:

(* ... *) are comments
- {20, 22} means: clear bits 20 and 22
+ {21, 23} means: set bits 21 and 23



Hi

My code is very similar

 LPC_SC->PCONP |= (1 << 26);

  /* set PIO0.10 and PIO0.11 to I2C2 SDA and SCL */
  /* function to 10 on both SDA and SCL. */
  LPC_PINCON->PINSEL0 &= ~((0x3<<20)|(0x3<<22));
  LPC_PINCON->PINSEL0 |= ((0x2<<20)|(0x2<<22));

  LPC_PINCON->PINMODE0 &= ~((0x3<<20)|(0x3<<22));
  LPC_PINCON->PINMODE0 |= ((0x2<<20)|(0x2<<22));

  LPC_PINCON->PINMODE_OD0 |= ((0x1<<10)|(0x1<<11));


  /*--- Clear flags ---*/
  LPC_I2C2->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;

  /*--- Reset registers ---*/
  LPC_I2C2->SCLL   = I2SCLL_SCLL;
  LPC_I2C2->SCLH   = I2SCLH_SCLH;

  /* Install interrupt handler */
  NVIC_EnableIRQ(I2C2_IRQn);

  LPC_I2C2->CONSET = I2CONSET_I2EN;


Now I tried to change the SCLL and SCLH values but don't work too,  I don't have any idea why my code don't work
0 Kudos

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Sun Sep 30 17:08:38 MST 2012
My guess is that the reference to P0.15 is an error.

Have you initialised the I2C interface for the LPC1769 before calling the functions you attached?

We do this in Oberon with the following code. It should not be too hard to translate to C:

    SYSTEM.PUT(MCU.PCONP, pconp + {26});
   (* Connect I2C2 signals *)
    (* P0.10 = SDA2, PINSEL0:21:20 = 10B *)
    (* P0.11 = SCL2, PINSEL0:23:22 = 10B *)
    SYSTEM.GET(MCU.PINSEL0, s);
    SYSTEM.PUT(MCU.PINSEL0, s - {20, 22} + {21, 23});
    (* no pull-up or pull-down *)
    (* PINMODE0:21:20 = 10B *)
    (* PINMODE0:23:22 = 10B *)
    SYSTEM.GET(MCU.PINMODE0, s);
    SYSTEM.PUT(MCU.PINMODE0, s - {20, 22} + {21, 23});
    SYSTEM.GET(MCU.PINMODE_OD0, s);
    SYSTEM.PUT(MCU.PINMODE_OD0, s + {10, 11})

If you are not familiar with Oberon code:

(* ... *) are comments
- {20, 22} means: clear bits 20 and 22
+ {21, 23} means: set bits 21 and 23
0 Kudos

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sun Sep 30 10:00:36 MST 2012

Quote: cfb
I have the EA Baseboard with the OLED not the Motor Control board but it is likely the steps would be similar:

1. Initialize I2C before calling any functions in oled.c

2. Uncomment the following define in oled.c:

#define OLED_USE_I2C

3. Make sure any jumpers on the board are inserted / removed according to the I2C/SPI OLED display section in the EA Motor Control User manual so that the OLED is connected to I2C.

Is that what you tried?



Hi

I made this way but in my board no have jumpers, my code is very similar to the sample code (really is the same), but I don't understand in the manual why LPC1769 in PWM mode use pins P0.10 and P0.11 (i guess is the correct) and in motor control IP block mode use P0.10 and P0.15 because p0.15 is not an I2c pin and is connected to UART-TXD

attached my code.

thank you for your answer
0 Kudos

405 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Sat Sep 29 16:35:01 MST 2012
I have the EA Baseboard with the OLED not the Motor Control board but it is likely the steps would be similar:

1. Initialize I2C before calling any functions in oled.c

2. Uncomment the following define in oled.c:

#define OLED_USE_I2C

3. Make sure any jumpers on the board are inserted / removed according to the I2C/SPI OLED display section in the EA Motor Control User manual so that the OLED is connected to I2C.

Is that what you tried?
0 Kudos