|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
18F4550 I2C not working on C3,C4 PIN |
Posted: Mon Dec 24, 2007 9:51 am |
|
|
Dear users,
I try to use a 18F4550 ( for replacement of a 16F877 ).
My code is working on 16F877, but the same code I2C don't work on the 18F4550.
When I use PIN C0,C1 ( In place of C3,C4 : hardware interface ?), I2C is working on the 18F4550.
Did you hear something about this ?
What's the problem ?
What can I do to work with 18F4550 and I2C hardware interface on C3,C4 ?
Best Regards
Eric
Code: | #include "D:\fichiers\CCS\test18f4550\test4550.h"
void OUT8574(byte adr,byte data)
{
I2C_start();
I2C_write((adr<<1> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
//#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOSTVREN //Stack full/underflow will not cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOCPD //No EE protection
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#use delay(clock=20000000)
#define EEPROM_SCL PIN_C3
#define EEPROM_SDA PIN_C4
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,enable=PIN_B1)
//#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3) => NOT WORKING
#use i2c(Master,Slow,sda=PIN_C1,scl=PIN_C0) => WORKING
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 24, 2007 12:06 pm |
|
|
1. Go to the "Data Sheet Finder" page on the Microchip website:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2046
2. Bookmark that page.
3. Use the dropdown box to select "PIC18F4550". Wait until it loads
the page for that PIC.
4. In the upper left corner, there is a link to download the data sheet
for the 18F4550. Download it.
5. Look at page 4 in the Acrobat Reader. It has a pin diagram of the
40-pin DIP version of the 18F4550.
6. Look down on the lower left side of the diagram. You see pins C0,
C1, and C2. In the place where Pin C3 should be, what do you see ?
7. Look at the lower right side of the pin diagram. You see pin C4.
What functions does it say that Pin C4 can do ? |
|
|
Guest
|
|
Posted: Mon Dec 24, 2007 4:11 pm |
|
|
Dear PCM Programmer,
Thanks a lot for the Quick Answer.
You are right, like this, it will never work
I search 6 hours about this problem...
I change my hardware, and now, it's working with PINB0-B1.
A little question : I use the same hardware for the PIC 16F877 and 18F4550.
So, for 16f877 this code, can not use hardware i2c interface.
#use i2c(Master,Fast,sda=PIN_B0,scl=PIN_B1,force_hw)
But it's working without error and the question is : how is it possible to know if hardware interface is used ?
There is no Warning error using this code for PIN B1,B0 and Hardware parameter for 16F877.
If I use this code for 18F4550, it will use Hardware interface ?
Best Regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 24, 2007 4:21 pm |
|
|
To enable the i2c library code for the hardware module, you must
do two things in the #use i2c() statement:
1. Specify the hardware i2c pins (labeled SDA and SCL in the PIC data sheet).
2. Specify the FORCE_HW parameter.
Both of those things must be true to use hardware i2c. |
|
|
Guest
|
|
Posted: Mon Dec 24, 2007 4:38 pm |
|
|
Thanks
Eric |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|