Jump to content
Sign in to follow this  
Greg

Another problem

Recommended Posts

Hi,

I am writing some code using the PIC16f877 and comunication with another chip, and printf is printing to the serial line.

I call this function ioRead twice within the program first time it runs fine and the second time as soon as it gets to the "clear_bit(PORTC,IOR);" bit it stops, it doesnt execute this, it just stops running then resets to the begining of the program, why does this happen?

 

here is a snippet of the code:

char ioRead(char addr) {
// set data bus to input
TRISB=0xff;
// set the address to the specified address
PORTA=addr;
printf("Ports initialised now set chipsel\n\r");
clear_bit(PORTC,CHIPSEL);
printf("Now set the IOR bit\n\r");
clear_bit(PORTC,IOR);
printf("now set value to be portb\n\r");
value=PORTB;
printf("Now reset the bits back\n\r");
set_bit(PORTC,IOR);
set_bit(PORTC,CHIPSEL);
printf("now return the value!\n\r");
return(value);
}

Thanks in advance, any help very much appreciated,

Greg

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...