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 support@ccsinfo.com

simulator

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



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

simulator
PostPosted: Wed May 05, 2004 11:06 am     Reply with quote

Hi,
I'm working on a I2c project. Here is code:
Code:

              void main() 
              {
                output_float(I2C_SCL);
                output_float(I2C_SDA);
                i2c_start();
                i2c_write(0x0f);
             }
             


However When I run mplab6.5 simulator, Only trisc register changes, sspcon2 and sspstat doesn't change at all. The arrow stop at #useI2c.
Does it mean I can not simulate I2c ?

Thanks
Simin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 05, 2004 11:27 am     Reply with quote

You are probably using software i2c.
To use hardware i2c:
1. Use a PIC that has a MSSP. (example: 16F877)
2. Specify the PIC pins that are dedicated to the MSSP
in your #use i2c statement. (example, pins C4 and C3 in the 16F877)
3. Add FORCE_HW to the end of your #use i2c statement.

Example:

#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, FORCE_HW)
dais



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

PostPosted: Wed May 05, 2004 2:11 pm     Reply with quote

Hi PCM,
Thanks for reply.
I use

#define I2C_SCL PIN_C3
#define I2C_SDA PIN_C4
#use i2c(MASTER, SDA = I2C_SCL, SCL = I2C_SDA, FORCE_HW)

Still not work
Is it Mplab 6.50 version matters or anything I did wrong?
Thanks
Simin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 05, 2004 2:20 pm     Reply with quote

Quote:
#define I2C_SCL PIN_C3
#define I2C_SDA PIN_C4
#use i2c(MASTER, SDA = I2C_SCL, SCL = I2C_SDA, FORCE_HW)

You are assigning the clock pin to the SDA signal, and the
data pin to the SCL signal. The compiler can only do hardware
i2c if you assign the pins correctly. So in the case above,
the compiler will ignore the Force_HW and just do software i2c.
dais



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

PostPosted: Wed May 05, 2004 3:01 pm     Reply with quote

PCM thanks, it works, sorry for the dummy mistakes, I shall check it carefully before I post. However, it stop at i2c_start() forever and never comes to i2c_write(). What's the problem?
Thanks
Simin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 05, 2004 3:59 pm     Reply with quote

Quote:
However, it stop at i2c_start() forever and never comes to i2c_write(). What's the problem?


If you click on View / Disassembly Listing, then click on that window,
then press F6 to reset the PIC, then press F8 to step through the
assembly code, you find that it's stuck in a loop, waiting for the
SEN bit of SSPCON2 to go low. It's waiting for the "start condition"
to finish.

So next, let's check the Help file:
In the MPLAB Help, under 18Fxxxx Limitations it says:
"Serial I/O (i.e., USART, I2C, SPI) is not simulated."
I'm using MPLAB vs. 6.42. So it appears that this version does not
simulate the MSSP in i2c mode.
Guest








PostPosted: Wed May 05, 2004 4:11 pm     Reply with quote

Thanks for teaching me how to use debugger.
Simin
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