driving HT16C21 I2C, LPC11XX

cancel
Showing results for 
Search instead for 
Did you mean: 

driving HT16C21 I2C, LPC11XX

537 Views
esam_me
Contributor II

Hello, I'm a beginner at ARM developing and I am struggling at the moment to drive an LCD_Driver "HT16C21" using the i2c example in Keil after modifying it. my MCU is lp1114/302. I modified PCF8594_ADDR in i2c.h to HT16C21 slave address which is 0x70. I also modified the I2C pins to new ones which I am using in i2c.c. Both files are attached and below is my main code and this is what I get in return on the terminal program(with nothing shown on the display!):

CMd Written!
CMd Written!
CMd Written!
CMd Written!
CMd Written!
data Written!

#include "LPC11xx.h"

/* LPC11xx Peripheral Registers */


#include "type.h"
#include "i2c.h"
#include "uart.h"

extern volatile uint32_t I2CCount;
extern volatile uint8_t I2CMasterBuffer[BUFSIZE];
extern volatile uint8_t I2CSlaveBuffer[BUFSIZE];
extern volatile uint32_t I2CMasterState;
extern volatile uint32_t I2CReadLength, I2CWriteLength;

/*******************************************************************************
** Main Function main()
*******************************************************************************/
//static uint8_t lcd_data[8] = { 0x10, 0x20, 0x30, 0x50, 0x60, 0x70, 0x80 };
typedef enum {

HT16C21_CMD_IOOUT = 0x80, /*!< Command to set as configuration Display Data RAM*/

HT16C21_CMD_DRIMO = 0x82, /*!< Command to set as Configuration device mode*/

HT16C21_CMD_SYSMO = 0x84, /*!< Command to set as Configuration system mode*/

HT16C21_CMD_FRAME = 0x86, /*!< Command to set as Configuration frame frequency*/

HT16C21_CMD_BLINK = 0x88, /*!< Command to set as Configuration blinking frequency*/

HT16C21_CMD_IVA = 0x8a, /*!< Command to set as Configuration internal voltage adjustment (IVA) setting*/

} ht16c21_cmd_t;
void write_cmd(uint8_t cmd_type, uint8_t cmd){
uint32_t i;

I2CWriteLength = 3;
I2CReadLength = 0;
I2CMasterBuffer[0] = PCF8594_ADDR;
I2CMasterBuffer[1] = cmd_type; /* address */
I2CMasterBuffer[2] = cmd; /*!< The drive mode 1/4 duty output and 1/3 bias is selected.*/
I2CEngine();
UARTSend((uint8_t *)"CMd Written! \r\n\r\n", 16);

for ( i = 0; i < 0x20000; i++ ); /* Delay after write */

/*for ( i = 0; i < BUFSIZE; i++ )
{
I2CSlaveBuffer[i] = 0x00;
}*/
}
void write_data(uint8_t wr_addr, uint8_t data){
uint32_t i;

I2CWriteLength = 4;
I2CReadLength = 0;
I2CMasterBuffer[0] = PCF8594_ADDR;
I2CMasterBuffer[1] = HT16C21_CMD_IOOUT;
I2CMasterBuffer[2] = wr_addr;
I2CMasterBuffer[3] = data;
I2CEngine();
UARTSend((uint8_t *)"data Written! \r\n\r\n", 16);
for ( i = 0; i < 0x20000; i++ ); /* Delay after write */

/*for ( i = 0; i < BUFSIZE; i++ )
{
I2CSlaveBuffer[i] = 0x00;
}*/
}

int main (void)
{
uint32_t i;

SystemCoreClockUpdate();

UARTInit(9600);
UARTSend((uint8_t *)"Hell0w0rld\r\n\r\n", 16);

if ( I2CInit( (uint32_t)I2CMASTER ) == FALSE ) /* initialize I2c */
{
UARTSend((uint8_t *)"i2c not intialized\r\n\r\n", 16);

for ( i = 0; i < 0x20000; i++ ); /* Delay after write */

/* while ( 1 ){
for ( i = 0; i < 0x20000; i++ ); // Delay after write

UARTSend((uint8_t *)"couldn't connect!\r\n\r\n", 16);

} // Fatal error
*/
}

write_cmd(HT16C21_CMD_DRIMO, 0x00);
write_cmd(HT16C21_CMD_SYSMO, 0x03);
write_cmd(HT16C21_CMD_FRAME, 0x01);
write_cmd(HT16C21_CMD_BLINK, 0x00);
write_cmd(HT16C21_CMD_IVA, 0x01);
write_data(0x00 , 0xFF );
}

  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
  • Im Wörterbuch speichern
    • Keine Wortliste für Englisch -> Arabisch...
    • Eine neue Wortliste erstellen...
  • Kopieren
Labels (1)
0 Kudos
2 Replies

482 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello ,

Hope you are doing well.

Could you provide wave forms of your i2c communication? This way we may know if the information is properly sent and received by both master and slave. It is difficult to tell if you are not getting any errors on software side. In addition it may be possible that your LCD  is not properly connected. Could you please verify your connections, if you have a schematic I may also check for you.

Best Regards,

Sabina

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

0 Kudos

482 Views
esam_me
Contributor II

I think it could be that new scl and sda pins are not configured properly! Can anybody pls. tell me if just replacing the default pins PIO0_4 and PIO0_5 with R_PIO1_2 and PIO3_0 in i2c.c was right?

0 Kudos