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

Could you help me about can_init

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



Joined: 09 Feb 2005
Posts: 48

View user's profile Send private message

Could you help me about can_init
PostPosted: Mon Feb 21, 2005 10:19 am     Reply with quote

Hi, everybody

I am trying to communicate two 16f877 using 2510 with help of can bus driven by mcp2551. I use the driver can-mcp2510.c. But, My pics don't make the can_init(); operation. This line never finished by pics. What can be wrong.

lcd_init();
can_init();
printf(lcd_putc,"I AM MASTER");

I never see the I AM MASTER on lcd but if I write like that

lcd_init();
printf(lcd_putc,"I AM MASTER");
can_init();
I see the I AM MASTER on lcd.

16F877 and MCP2510 There is a 4 connection pins. I never use the int pin of the mcp2510. sck,so,si,cs. I changed the CS pin from the file can-mcp2510.c . The others remain constant. Xtal:4mhz used for mcp2510.
help me please!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 21, 2005 10:36 am     Reply with quote

You don't have to keep posting over and over again.
We saw your post the first time.

If a program stops when it talks to a hardware driver,
the reason is probably that it's waiting in a polling loop.
It's reading the device and waiting for a bit to be in
a certain state (high or low) and the bit never goes
into that proper state. So the program stays in that
loop forever.

So, you should look at the code in the can_init() function.
Look for places where it reads the MCP2510. Also, look
in all sub-routines that are called by can_init().
When I do this, I find the following code in can_set_mode():
Code:
 do {
      old_CANCTRL=mcp2510_read(CANCTRL);
   } while (old_CANCTRL.reqop != mode);

This may be where the problem is. One easy way to check
is to temporarily put some printf or putc statements before and
after that code. Something like this:
Code:
putc('A');
 do {
      old_CANCTRL=mcp2510_read(CANCTRL);
   } while (old_CANCTRL.reqop != mode);
putc('B');

Now run your program. If you see "AB" on the terminal window,
then it's executing that section OK. But if you only see "A",
then the program is stuck in that section.

You should do this. If it locks up in that section, then look closely
at your MCP2510 SPI bus signals. Do you have them connected
properly ? You said you moved the CS signal. What pin did you
put it on ? Is another device (such as the LCD) connected to
any of those SPI pins ? Did you put CS on pin A4, and then forget
to put a pull-up resistor on that pin ? Look for things like this.
sraiderk



Joined: 09 Feb 2005
Posts: 48

View user's profile Send private message

PostPosted: Tue Feb 22, 2005 3:55 am     Reply with quote

Thank you very much your help. I saw A then I made pull up correction on my circuit. It is fine.
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