Documente Academic
Documente Profesional
Documente Cultură
1 trong 6
Login
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
Register
FAQ
Search
Author
reab
Message
Post subject: I2C on a PIC18F4620 not working at all . . .
I've upgraded my application from 16F877a - 18F452 to a PIC18F4620. I've managed to find work arounds for many issues
but this latest one defies me. I2C refuses to work and as I store many of my LCD message strings in a 512kbit device
(which up to now has worked perfectly) it causes me a few issues.
The data sheet for PIC18F4620 states that I should separately initialise the port pins but I'm struggling with this.
So far this is a snippet of how I set it up - I use ME's I2C library in my routines which up to now have worked well:
Code: Select all
PORTA
0;
TRISA
0;
PORTB
0;
TRISB
0;
PORTC
0;
TRISC
0;
PORTD
0;
TRISD
0;
TRISE
0;
PORTE
0;
ADCON1 =
0x0F;
PORTA.F5 = 1;
PORTC.F3 = 1;
PORTC.F4 = 1;
SSPCON1.SSPEN = 1;
Have I used the correct syntax and is it the correct order and which of the I2C pins (RC3/RC4) are input or output?
Any pointers would be helpfull - original thread was: http://www.mikroe.com/forum/viewtopic.php?t=4400
Roger B
_________________
Be kind and like your words - you never know, you may have to eat them one day!
Top
reab
Just a little bit of update information. After working at this I've now changed and used the soft I2C library routines
instead on this device and all seems to work ok again. Only question is why as the data sheet seems to state that apart
from possible register settings it should be compatible with the earlier devices.
4/22/2015 3:41 PM
2 trong 6
Posts: 263
Location: West Sussex,
United Kingdom
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
Top
pizon
_________________
pizon
Top
boattow
Hi,
I found this post and others where it seems that people are not getting I2C to work on the PIC18F4620. There was never
any resolution posted here.
I have a project using MEBasic. I was using the PIC18F4550. It talks to the character LCD, A2D (displays battery
voltage), talks to user hardware, reads buttons, and of course talks to several devices over I2C such as the Philips real
time clock. I started running out of program memory so I got a PIC18F4620 which looks to be virtually the same chip as
the 4550 except the lack of USB but twice the memory. I put it in after programming it and it seems to work as it
displays the opening LCD message and the battery voltage but seems to stop working when it gets to the I2C comm with
the RTC. Is there a change I need to make in software or configuration bits when changing controllers? I set the flash
program software to the new processor, changed it from 48Mhz to 40Mhz as well as the crystal but not working, just as
others have stated in other posts here. Anyone have any ideas?
Thanks,
FJ
Top
Bob Lawrence
Top
bobbydavro
Post subject:
Just wondering could you implement a I2C eeprom on your old chip?
Joined: 13 Nov 2007 14:50
Posts: 64
Location: UK
Top
srdjan
mikroElektronika team
Post subject:
Hi,
Refer to this post
http://www.mikroe.com/forum/viewtopic.php?t=12648&highlight=i2c
4/22/2015 3:41 PM
3 trong 6
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
Location: Serbia
Top
boattow
Bobbydavro:
Using the 18F4550 I had this communicating with a 24lc256 EEPROM, PCF8583 RTC, and 2 slave PICs in I2C slave mode.
The code for the EEPROM is just the MEBasic example only 2 bytes used to address it.
FJ
Last edited by boattow on 06 Feb 2008 13:42, edited 1 time in total.
Top
srdjan
boattow wrote:
mikroElektronika team
Using the 18F4550 I had this communicating with a 24lc256 EEPROM, PCF8583 RTC, and 2 slave PICs in I2C slave
mode. The code for the EEPROM is just the MEBasic example only 2 bytes used to address it. I think the erata that
Bob posted will be the answer. I just won't be able to try it until this evening.
FJ
Joined: 28 Dec 2005 12:47
Posts: 1552
Location: Serbia
Yes, the post I have referred you to has the exact portion of the errata, Bob was talking about, which is describing the
silicon bug causing the pic18f4620 i2c module not to work and the appropriate workaround.
Top
boattow
Top
boattow
Thanks to Bob and SRDJAN, it works now. I greatly appreciate your help.
FJ
Joined: 08 Mar 2007 03:00
Posts: 60
Top
Bob Lawrence
boattow,
Joined: 18 Aug 2004 11:55
Posts: 300
Location: Lwr Sackville, Nova
Scotia, Canada
Bob
Top
dronology
Post subject:
18f4620's Pin map seems so similar to 16F877. But 18f4620 contains more complicated structure. For ex. 877's RB port
doesn't contain any Analog input but 4620 contains and so on. So you have to set your initial values (if you want to use
RB as digital i/o you need to disable ADCON and etc.) at the beginning of your code.
I wrote codes (some functions) for serial eeproms 1 week ago based on SoftI2C's. In these functions I'll give more than
you need (not only serial eprom functions but also ploting them on your GLCD function).
4/22/2015 3:41 PM
4 trong 6
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
location of mem).
void write_char(int high_addr, int low_addr, unsigned char *ch);
//Reads text
of given mem address and space and writes that text to GLCD (T6963)
void write_text_to_memo(int high_addr, int low_addr, char *text);
// device address
//24C256 and 24C512 Serial EEPROM: reads text from EEPROM and writes it to LCD
void write_text_to_lcd(int high_adr, int start_adr, int end_adr, int coordx, int coordy){
int i_;
for (i_=start_adr; i_<end_adr; ++i_){
read_char(high_adr, i_, &take[i_-start_adr]);
if(take[i_-start_adr]=='^'){
take[i_-start_adr]=' ';
Zero_Fill(take);
4/22/2015 3:41 PM
5 trong 6
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
break;
}
}
T6963C_write_text(take, coordx, coordy,1);
//clears take array
for (i_=0; i_<35; ++i_){
take[i_]=0;
}
}//~ end of function
Soft_I2C_Write(0xA0);
// device address
value[1] = value[0];
value[0] = 48;
value[2] = 0;
}
}//~ end of function
In my programs the array of take[35] defined globally. It is being used as a ALU. After each operation if you keep it
empty you ca your main program You need to
and this part of write_text_to_lcd function:
if(take[i_-start_adr]=='^'){
take[i_-start_adr]=' ';
Zero_Fill(take);
break;
}
I splited the string datas of in the serial eeprom by using "^" symbol. When the program read cycle comes to this line it
will see this symbol and when reading from eprom it will cut its reading. This is a some kind of end of line. But you
don't need to act like this. Only address info will be enough for you as it is described in write_text_to_memo function,
on the other meaning only and only start address and size of text is enough for putting your string to exact location and
4/22/2015 3:41 PM
6 trong 6
https://www.mikroe.com/forum/viewtopic.php?f=13&t=4678
getting end of it. In these technics write_text_to_lcd and write_text_to_memo functions differ from each other. But
both of them work.
Kind Regards,
D.ELMASLI
_________________
R. Giskard Reventlov & R. Daneel Olivaw
http://www.circuitechs.com
http://www.dronology.com
Top
Ascending
Go
Page 1 of 1 [ 13 posts ]
Board index Compilers mikroC Compilers Older versions of mikroC Compilers mikroC for PIC mikroC General
Who is online
Users browsing this forum: No registered users and 4 guests
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Search for:
Go
Jump to:
mikroC General
Go
4/22/2015 3:41 PM