Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
point 2 Do Rigol really charge 180 quid to licence I2c trigger and decode, My 30 hours nearly up ....
I noticed Microchip told me how bad my code was and suggest I send them some of my pension , to make it run better...
Hi Nigel, I don't recall any compile speed problems with XC16 , but my stuff was not that big ... ,What PIC24 are you using...
I'm guessing you want to compare the LCD init string ?... .. I need to go search files.. ... as I have swapped PC as well...can you share your lcd code so i can compare it to my code?
char LCD_init_data[]={0x00,0x39,0x14,0x7A,0x50,0x6C,0x0C,0x01}; // LCD Init string
void LCD_init()
{
unsigned int x;
I2C1ADB1 = 0x7C; // load addr 7c
I2C1CNT=0x08; // load I2C1CNT with number of INIT bytes
for(x=0;x<8;x++){
I2C1TXB = LCD_init_data[x];
while(!I2C1STAT1bits.TXBE); // wait for buffer empty
}
while(!I2C1PIRbits.PCIF); // WAIT FOR STOP.
//serial_print(serial_mess3,1);
__delay_ms(100);
}
void LCD_Init(unsigned int slave_Adress)
{ //Initialize lcd
//set 8bit to 4bit
int data1[32] = {0x3C, 0x38, 0x3C, 0x38, 0x3C, 0x38, 0x2C, 0x28,
//send in 4bits
//4-bit mode initialization complete. Now configuring the function set
0x2C,0x28,
0x8C,0x88,
//Next turn display off
0x0C, 0x08,
0x8C, 0x88,
//Display clear, cursor home
0x0C, 0x08,
0x1C, 0x18,
//Set cursor direction
0x0C, 0x08,
0x6C, 0x68,
//Turn on the display. Set cursor and blink here
0x0C, 0x08,
0xCC, 0xC8,
//send letter "H"
0x4D, 0x49,
0x8D, 0x89
};
// Write operation (W/R bit = 0)
I2C1ADB1 = (slave_Adress<<1)|0;
int totalByteLength = 32;
I2C1CNT = totalByteLength;
I2C1CON0bits.S=1; //Start
for(int i = 0; i < totalByteLength; i++){
__delay_ms(15);
// Write to TXB starts communication
I2C1TXB = data1[i];
//Wait until TXB is empty
while(!I2C1STAT1bits.TXBE);
}
while(!I2C1PIRbits.PCIF); // WAIT FOR STOP.
__delay_ms(100);
}
void interrupt DATA_IN(void)
{
if(PIR1bits.SSPIF){
while(SSPSTATbits.BF){
I2C_BUF[B_free][SBW] = SSPBUF;
SBW++;
}
if(SSPSTATbits.P){
B_has_data++;
B_free++;
B_free=B_free & 0x0007; // 0-3 buffer numbers
if(B_free==0)B_free=1;
SBW=0;
}
PIR1bits.SSPIF=0;
}
return;
// process other interrupt sources here, if required
}
void EN_interrupts()
{
char dummy;
INTCONbits.PEIE_GIEL=1;
INTCONbits.GIE_GIEH=1;
PIE1bits.SSPIE=1; // enable i2c interrupt.
dummy = SSPBUF;
PIR1bits.SSPIF=0;
}
void I2C_init() // mssp driver
{
SSPSTAT = 0x00; // Slew rate
SSPCON1 = 0x26; // SSPEN = 1, I2C Slave mode ,
SSPCON2 = 0X00; //
SSPADD = 0x44; // SLAVE ADDRESS
}