uint8_t Byte=0x00;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
Byte=0x38;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
Byte=0x39;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
Byte=0x14;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
Byte=0x78;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
Byte=0x5E;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
Byte=0x6D;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
R_BSP_SoftwareDelay(300, BSP_DELAY_UNITS_MILLISECONDS);
Byte=0x0E;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
Byte=0x01;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
R_BSP_SoftwareDelay(2, BSP_DELAY_UNITS_MILLISECONDS);
Byte=0x06;
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 1 , false);
R_BSP_SoftwareDelay(2, BSP_DELAY_UNITS_MILLISECONDS);uint8_t Byte[10]={0x00,0x38,0x39,0x14,0x78,0x5E,0x6D,0x0E,0x01,0x06};
g_i2c0.p_api->write(g_i2c0.p_ctrl, &Byte, 10 , false);El driver es bastante confuso, para empezar dice que la dirección es 0x78 pero en el ejemplo de la trama manda 7C, busacndo por internet he visto que muchos mandan el 0x3C ya que el 0x78 es el 0x3C con un 0 mas del R/W.
si inicializo con los siguientes codigos deberia ver por pantalla el cursor parpadeando no?
void init_LCD()
{
DSPL_RST_ON;
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
DSPL_RST_OFF;
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
I2C_Start();
I2C_out(0x78);//Slave=0x78
I2C_out(0x00);//Comsend = 0x00
I2C_out(0x38);
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
I2C_out(0x39);
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
I2C_out(0x14);
I2C_out(0x78);
I2C_out(0x5E);
I2C_out(0x6D);
I2C_out(0x0E);
I2C_out(0x01);
I2C_out(0x06);
R_BSP_SoftwareDelay(10, BSP_DELAY_UNITS_MILLISECONDS);
I2C_Stop();
}
void I2C_out(unsigned char j) //I2C Output
{
int n;
uint8_t d;
ioport_level_t level;
d=j;
for(n=0;n<8;n++)
{
if((d&0x80)==0x80)
SDA_ON;
else
SDA_OFF;
d=(uint8_t)(d<<1);
SCL_OFF;
SCL_ON;
SCL_OFF;
}
SCL_ON;
while(level==1)
{
g_ioport.p_api->pinRead(SDA, &level);
SCL_OFF;
SCL_ON;
}
SCL_OFF;
}
void I2C_Start(void)
{
SCL_ON;
SDA_ON;
SDA_OFF;
SCL_OFF;
}
void I2C_Stop(void)
{
SDA_OFF;
SCL_OFF;
SCL_ON;
SDA_ON;
}
void Show(unsigned char *text)
{
int n;
I2C_Start();
I2C_out(0x78); //Slave=0x78
I2C_out(0x40);//Datasend=0x40
for(n=0;n<20;n++)
{
I2C_out(*text);
++text;
}
I2C_Stop();
}Recorda dejar un tiempo de al menos 50 a 100ms antes de enviarle algo al LCD, debido a que esta inicializandose, supuestamente este se inicializa solo
Display_Trama[0]=0x78;
Display_Trama[1]=0x00;
Display_Trama[2]=0x0F;
ssp_err_t err = g_i2c0.p_api->write(g_i2c0.p_ctrl, &Display_Trama[0], 3 , true);
if (SSP_SUCCESS != err)
{
//Ha ocurrido un error
err=0;
}
ssp_err_t err = g_i2c0.p_api->open (g_i2c0.p_ctrl, g_i2c0.p_cfg);
if (SSP_SUCCESS != err)
{
err=0;
//Ha ocurrido un error
}
DSPL_RST_ON;
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
err = g_i2c0.p_api->reset (g_i2c0.p_ctrl);
if (SSP_SUCCESS != err)
{
err=0;
//Ha ocurrido un error
}
DSPL_RST_OFF;
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);To write an I2C application using the IIC, follow these steps. TheCódigo: C
g_i2c.p_api->open()
function must be called first. The rest of the calls may be used in any order depending on the application requirements:
1) Configure the module by setting up the structures i2c_cfg_t.Once the module is configured, the module related
header and configuration files are generated automatically.
2) Open an I2C instance with the I2C implemented by IIC.The IIC driver is called through the I2C InterfaceCódigo: C
g_i2c.p_api->open (g_i2c.p_ctrl, g_i2c.p_cfg)
where p_ctrl and p_cfg are the instances of control and configuration structures auto generated after the I2C configuration step.
3) Initiate a write to a slave device by callingCódigo: Cwhere g_i2c.p_ctrl is the same control instance that was used in the open call. The last argument specifies whether the write should be followed by a restart condition (set to true) or a stop condition (set to false). A Restart condition is typically used if the master does not want to relinquish the bus between successive read/write calls.
g_i2c.p_api->write(g_i2c.p_ctrl, &write_buffer,num_bytes_to_write, false)
4) Initiate a read from a slave device by callingCódigo: Cwhere g_i2c.p_ctrl is the same control instance that was used in the open call. The last argument specifies if the read should be followed by a restart condition (set to true) or a stop condition (set to false).
g_i2c.p_api->read(g_i2c.p_ctrl,&write_buffer,num_bytes_to_write, false)
5) If there is a need to reset the IIC peripheral, do so by callingCódigo: Cwhere g_i2c.p_ctrl is the same control instance that was used in the open call.
g_i2c.p_api->reset(g_i2c.p_ctrl)
6) To close the IIC channel, do so by callingCódigo: C
g_i2c.p_api->close(&g_i2c, p_ctrl)
where g_i2c.p_ctrl is the same control structure that was used in the open call
me parece que tendré que comprarme un analizador lógico para ver que esta pasando, conocéis alguno que tenga buen stock y sea barato? me gustaba el de saleae, pero me parece que ya no lo venden.
un saludo.
Ahora que sacais el tema, perdonadme que os pregunte si creeis que merecera la pena el analizador logico que traen los osciloscopios de Pico o mejor un analizador aparte de Saleae?
y las copias baratas de Saleae, teneis alguna opinion de ellas ?