Hello im new on the forum and i have a big problem..
im going to do a matrix of led RGB 5x5, that i can control with the raspberry pi 2 the problem is that i need more outputs thats why i want to connect with a pic 16f886 through the protocol i2c.
but i dont find any guide how can i do this program in mikro c if somebody can help me i would appreciate
thanks
pic16f886 + i2c+ raspberry pi
- lana.arsic
- mikroElektronika team
- Posts: 1715
- Joined: 15 Jan 2016 12:50
Re: pic16f886 + i2c+ raspberry pi
Hi superino,
Welcome to the MikroE forum.
I suggest you to use our 4x4 RGB click:
http://www.mikroe.com/click/4x4-rgb/
and one of our clicker boards:
http://www.mikroe.com/clicker/
Best regards,
Lana
Welcome to the MikroE forum.
I suggest you to use our 4x4 RGB click:
http://www.mikroe.com/click/4x4-rgb/
and one of our clicker boards:
http://www.mikroe.com/clicker/
Best regards,
Lana
Re: pic16f886 + i2c+ raspberry pi
hii lana.arsic i already desing my matriz of leds im just having problem with the code to write in mikro c to make the pic as slave i just need he recive 2 bytes of information.
i try to conect the pic with
vdd 5v
vss ground
scl scl raspi
sda sda raspi
and dont detect the pic i dont know if i have problems with the code..
i try to conect the pic with
vdd 5v
vss ground
scl scl raspi
sda sda raspi
and dont detect the pic i dont know if i have problems with the code..
- lana.arsic
- mikroElektronika team
- Posts: 1715
- Joined: 15 Jan 2016 12:50
Re: pic16f886 + i2c+ raspberry pi
Hi superino,
Unfortunately, mikroC provides library which supports only the master I²C mode,
but maybe you can find these threads useful:
http://forum.mikroe.com/viewtopic.php?f=97&t=8106
http://forum.mikroe.com/viewtopic.php?t=3223
Or, maybe you can consider to use UART instead.
Best regards,
Lana
Unfortunately, mikroC provides library which supports only the master I²C mode,
but maybe you can find these threads useful:
http://forum.mikroe.com/viewtopic.php?f=97&t=8106
http://forum.mikroe.com/viewtopic.php?t=3223
Or, maybe you can consider to use UART instead.
Best regards,
Lana
Re: pic16f886 + i2c+ raspberry pi
I agree with this answer, you will use the same amount of pins and UART in my opinion is easier to implement for one or two way control.lana.arsic wrote:Or, maybe you can consider to use UART instead.
other options would be using shift registers or port expander to save on programming and maybe speed increase. The world is your canvas, plenty of options so don't get fixated on only one.
Re: pic16f886 + i2c+ raspberry pi
This is the code im doing but my raspberry still dont detect the pic.. i try to use internal oscilator INTOSC or INTOSCIO using 8Mhz please if sombody know any anwserrrr
Code: Select all
void Init(){
ADCON1 = 0; // All ports set to digital
TRISA= 0X00;
TRISB= 0X00;
TRISC= 0b00011000; // puerto C a salida
TRISC3_bit = 1; // Configurar I2C SCL pin
TRISC4_bit = 1; // Configurar I2C SDA pin
SSPADD= 0X69;
SSPCON = 0x36; // Direccion esclavo
PIE1.SSPIF = 1; // enable SSP interrupts
INTCON = 0xC0; // enable INTCON.GIE
OSCCON.IRCF0=1;
OSCCON.IRCF1=1;
OSCCON.IRCF2=1;
}
void interrupt(){
if (band == 0 ){ //
if (PIR1.SSPIF == 1){ // I2C Interrupcion
PIR1.SSPIF = 0; // reinicia la bandera
}
if (SSPSTAT.BF == 0){ // all done,
color = SSPBUF;
band=1; // bandera en uno
return;
}
}
//recieve data from master
else{
if (SSPSTAT.D_A == 1){ // Data
byte = SSPBUF; // get data
return;
}
}
}
Re: pic16f886 + i2c+ raspberry pi
Code: Select all
TRISC3_bit = 1; // Configurar I2C SCL pin
TRISC4_bit = 1; // Configurar I2C SDA pin
Code: Select all
PIE1.SSPIF = 1; // enable SSP interrupts
Code: Select all
PIE1.SSPIE = 1; // enable SSP interrupts
Code: Select all
if (SSPSTAT.D_A == 1){ // Data
byte = SSPBUF; // get data
return;
other than those minor points, I am not sure where the problem lies, maybe you can zip your code and post here or if it is sensitive maybe open help request and give them the specifics