Jump to content

Can't I Assigned An Address Casting To A Sfr? See Example

Recommended Posts

What is wrong with this ....



#include <pic16F685.h>


#define BANK_0 0x0000


#define IOPORTC ((unsigned volatile *)(BANK_0 + PORTC))

#define IOTRISC ((unsigned volatile *)(BANK_0 + TRISC))



.. later on in a function definition ...


*IOTRISC &= ~SEGMENT_MASK; // By writing zero's to the bits that correspond to segments, we set them all to outputs


This generates a non descriptive error (general error).


The code is included as an attachment.


Thanks for the help...


Link to post
Share on other sites

Please don't use volatile and use intermediate temporary. Something like:


#define IOTRISB ((unsigned*)(BANK_0 + TRISB))


unsigned *tris = IOTRISB;
*tris &= ~SEGMENT_MASK;





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.

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.

  • Create New...