Jump to content
Sign in to follow this  
asianlink

Why this is not working?

Recommended Posts

I try to turn on first 4 ports of 12c508 but it doesn't seem to work!  Please someone tell me why?  Thanks!!!

 

char trisio@0xF; //map variable

char gpio@0x5; //map variable

 

void main(void)

{

   trisio = 0;    //set all IOs to output

   gpio = 0;     //clear gpio

   While( 1 )

   {

       gpio = 0xF; //first 4 port high

   }

}

 

/* EOF */

Share this post


Link to post
Share on other sites

I had the same problem on a 16F84A.

The compiler doesn't do the bank switching for you, but I believe it should!? - Admin.

 

Try this:

   set_bit( STATUS, RP0 );

   TRISB = 0;

   clear_bit( STATUS, RP0 );

Share this post


Link to post
Share on other sites
Guest Pavel

The built-in functions (like set_bit or set_tris_) don't set the correct register bank. That's the reason why some of them are marked as 'obsolete'.

However if variables with fixed addresses are used that the compiler always sets the correct register bank.

I recommend always use variables with fixed addresses if you need to access registers from C code.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Pavel
Why am I using the Fixed Address above but it still doesn't work?  :D

Are you sure that 12c508 has gpio at register 0x5 and trisio at register 0xF? The 12c508 datasheet defines a bit different register map  ::(:

 

Regards,

Pavel

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...