CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

hardware i2c and spi on PIC24FJ64?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

hardware i2c and spi on PIC24FJ64?
PostPosted: Thu Mar 01, 2012 12:23 am     Reply with quote

From various searches, it seems that the consensus is if you want to use SPI and i2c, you should do one as hardware and one as software, unless there are two hardware modules; can someone confirm my interpretation of the PIC24FJ64GA004 spec sheet as indicating it does indeed have multiple hardware modules, and that it's best to use the hardware for both SPI and i2c?
If both hardware, is it best to use i2c1 and SPI2, just to make sure there's no crossover between them?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 12:54 am     Reply with quote

Your assumption is wrong, PIC24 SPI and I2C hardware modules are independent of each other.

For 24FxxxG004 family, hardware SPI can refer to any available RPxx pins, I2C is restricted to the respective dedicated pins.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 3:24 am     Reply with quote

Thanks FvM, I didn't exactly assume they were interconnected, but had read a few things about previous PICs using the same hardware for both systems, so thought maybe it's best to not risk a conflict if I had the pins / layout available.
Had also read something about SDI1 not compiling correctly with certain versions of CCS, and that it kept recurring in subsequent releases. At the moment I'm probably only using 1/4 of the pins available, so if I can remap and avoid systems that may or may not be buggy, then possibly it might save me hours/days trying to track down a fault.

Not that I've even got it breadboarded yet, still got the old PIC18F2620 in the breadboard, and haven't connected up any of the I2C or SPI stuff; figure I may as well make the jump to the 24F first before going any further.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 6:09 am     Reply with quote

Yes, PIC18 has a common SPI/I2C module.

Previous PCD versions had various issues, also related to peripheral pin select functionality and SPI built-in functions. Recent versions are performing well at least with all popular chips. In case, you have still the option to implement an intended function by accessing SFRs directly.

Quote:
figure I may as well make the jump to the 24F first before going any further
You should definitely try, I guess you'll like it.
jeremiah



Joined: 20 Jul 2010
Posts: 1349

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 8:22 am     Reply with quote

I work with that exact PIC in a lot of projects, including some that involve I2C. Just some notes:

1. Take a look at the errata for that PIC (available from Microchip's website). There are some issues with earlier revisions of the chip's I2C module. If you can, try to get a PIC with a lot number starting with 10 (I think if it starts with 09 that is still ok. I know most of the 08 ones had some old problems). That's the year the lot was done. The earlier revision of the chip (I want to say A3 and A4 off the top of my head) had some I2C issues, though there are work arounds if you do have an older revision.

2. I've actually had trouble running I2C2 as hardware. It's supposed to work, but I have yet to get it there (probably I am doing something wrong, but I tried disabling everything I could on those pins and still had no luck). I've had no problems out of I2C1 though, well with #1 taken into account. What I have done to work around those problems was, if I needed to use I2C2 for something, I tried to make sure it was the simpler module and used a SW I2C on it.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 9:04 pm     Reply with quote

Thanks jeremiah; is that the number like "1002GUA" on the end? If so, then yeah I've got "10" ones at the moment (obviously). I'd imagine any future purchases direct from Microchip would be later dated, or should I still keep an eye out?

Good to know about the I2C2, I was going to only be using I2C1 anyway but always nice to know any potential issues. At the moment I only have to interact with one I2C chip and one SPI chip, so hopefully issues will be minimised. Being SMD chips, I need to make breakout boards anyway, so I'm leaning more towards getting the entire hardware design finished and some cheap "proper" boards made up by Seeed, so hardware should be good and just have to tweak the coding. In theory.
jeremiah



Joined: 20 Jul 2010
Posts: 1349

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 9:42 pm     Reply with quote

Yes, that should be the lot number. The first two digits are the 2 digit year. It isn't easy to tell a specific lot number by that, but if you look at the revision history of the errata you can get a general idea of when a particular revision was released and if your lot number is higher, there is a good chance you have that revision or newer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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