Constants to SFRs

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Constants to SFRs

#1 Post by JimKueneman » 28 Jan 2011 16:10

Is this possible? I want to have the pointer addresses of SFR's in a global constant so I tried this:
const
UART_XPRESSBUS_REG_TX = @U2TXREG;
UART_XPRESSBUS_STATUS_TX = @U2TXREG;
UART_PC_REG_TX = @U1TXREG;
UART_PC_STATUS_TX = @U1TXREG;

begin
if UART_PC_STATUS_TX^.URXDA = 1 then
....
It compiles but the if statement fails.

This works:

Code: Select all

type
  PWord = ^Word;
  
var
  UART_XPRESSBUS_REG_TX: PWord;
  UART_XPRESSBUS_REG_RX: PWord;
  UART_XPRESSBUS_STATUS: PWord;

  UART_PC_REG_TX: PWord;
  UART_PC_REG_RX: PWord;
  UART_PC_STATUS: PWord;

begin
  UART_XPRESSBUS_REG_TX := @U2TXREG;
  UART_XPRESSBUS_REG_RX := @U2RXREG;
  UART_XPRESSBUS_STATUS := @U2STA;
  UART_PC_REG_TX := @U1TXREG;
  UART_PC_REG_RX := @U1RXREG;
  UART_PC_STATUS := @U1STA;

begin
  if UART_PC_STATUS_TX^.URXDA = 1 then
   ....
I don't want to use 4 words of memory to do this with variables

Thanks,
Jim

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Constants to SFRs

#2 Post by zristic » 31 Jan 2011 14:07

Ok, it took me a while to get the point, but I see you are right.
I have added to our wish list this idea, probably we will realize it.
Thanks for the tip.

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”