This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

struct pointing to RTC in far memory location.

I have a Real Time Clock (RTC) located at address 0x180000

I would like to create a struct of the RTC registers and map it to 0x180000 where the RTC registers start, located in far xdata memory or (HDATA).

I want to access the RTC such as

 RTC.Month = 8; 

Would I use the FVAR or far * in some way to accomplish this?

Thanks for your help..

Parents
  • This is what I came up with that works, it is accessing the RTC at 0x180000.

    #define RTC_ADDRESS (0x180000ul)
    
    typedef struct RTC_REGS
    {
    	unsigned char hsec;
    	unsigned char sec;
    	unsigned char min;
    	unsigned char min_alarm;
    	unsigned char hour;
    	unsigned char hour_alarm;
    	unsigned char day;
    	unsigned char day_alarm;
    	unsigned char date;
    	unsigned char month;
    	unsigned char year;
    	unsigned char cmd;
    	unsigned char wd_hsec;
    	unsigned char wd_sec;
    	unsigned char dummy1;
    	unsigned char dummy2;
    	unsigned char user[48];
    } RTC_regs;
    
    RTC_regs far *RTC_registers = &FVAR(RTC_regs, RTC_ADDRESS);
    
    void RTC_Init( void )
    {
    		RTC_registers->hsec = 0;
    		RTC_registers->sec  = 0;
    		RTC_registers->min  = 0;
    }
    

Reply
  • This is what I came up with that works, it is accessing the RTC at 0x180000.

    #define RTC_ADDRESS (0x180000ul)
    
    typedef struct RTC_REGS
    {
    	unsigned char hsec;
    	unsigned char sec;
    	unsigned char min;
    	unsigned char min_alarm;
    	unsigned char hour;
    	unsigned char hour_alarm;
    	unsigned char day;
    	unsigned char day_alarm;
    	unsigned char date;
    	unsigned char month;
    	unsigned char year;
    	unsigned char cmd;
    	unsigned char wd_hsec;
    	unsigned char wd_sec;
    	unsigned char dummy1;
    	unsigned char dummy2;
    	unsigned char user[48];
    } RTC_regs;
    
    RTC_regs far *RTC_registers = &FVAR(RTC_regs, RTC_ADDRESS);
    
    void RTC_Init( void )
    {
    		RTC_registers->hsec = 0;
    		RTC_registers->sec  = 0;
    		RTC_registers->min  = 0;
    }
    

Children
No data