I am developing standard API's for MSP430G2553 Launchpad. I have 2 different ways of setting clock source of Timer0. In both cases, i am trying to access the TA0CTL register to set the bits for selecting clock source. But the way I am trying to access is different. Below are the two ways and I get warnings in both cases:
First Method:
void set_clk_src_Timer0(unsigned short int clk_src)
{
void *ptr;
ptr=TACTL;
struct timer_control_register *TACTL_0;
TACTL_0 = (struct timer_control_register*)ptr;
TACTL_0->TSSEL = clk_src;
}
Warning : TACTL is of unsigned int type and cannot be assigned to type void*
Hence I assigned the address of TACTL in below method.
Second Method:
void set_clk_src_Timer0(unsigned short int clk_src)
{
void *ptr;
ptr=&TACTL;
struct timer_control_register *TACTL_0;
TACTL_0 = (struct timer_control_register*)ptr;
TACTL_0->TSSEL = clk_src;
}
Warning: TACTL is of type volatile unsigned int * and cannot be assigned to type void *
I see below declarations in the MSP430G2553 header file
#define SFR_16BIT(address) extern volatile unsigned int address
#define TACTL TA0CTL
SFR_16BIT(TA0CTL)
Please explain me following doubts:
1. What actually SFR_16BIT(address) declares?
2. How the register name actually gives register address?