Jump to content


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

1 reply to this topic

#1 usafirmware



  • Members
  • 1 posts

Posted 28 May 2012 - 01:42 AM

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

Attached Files

#2 Pavel


    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 1,451 posts
  • Gender:Male
  • Location:Melbourne, Australia

Posted 28 May 2012 - 06:15 AM

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

#define IOTRISB ((unsigned*)(BANK_0 + TRISB))
unsigned *tris = IOTRISB;
*tris &= ~SEGMENT_MASK;


Reply to this topic


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users