Hello people. I am new to programming at all. Please help, I have been writing an UART0 initialisation for A0 module (MSP432 launchpad). Everything went on fine, until I started trying to switch on interrupts. The point is, when I try to write into UCA0IE register in order to enable transmit and receive interrupts - nothing is written! After a writing operation the register remains intact, its value doesn't change. I have checked with the debugger, just nothing is being written!! I have checked the address, according to the datasheet, it seems that I write to a correct address. At the same time when I write to any other eUSCI_A0 registers - everything writes very fine with no any problem! Also, when I try to write into IPR4 to set up priority for UART_A0 interrupt - also nothing writes there!! At the same time when I write into ISER0 to enable IRQ16 - everything writes fine. Please help! I cannot understand what is going on. Here is the code which doesn't work. #define UCA0IE (*(unsigned volatile short *)0x4000101a) #define IPR4 (*(unsigned volatile long *)0xe000e410) ... UCA0IE=3; //After this line nothing changes in UCA0IE!! IPR4|=3; //After this line nothing changes in IPR4!! Guyz please help me out. Here I will include the whole function just in case. Thank you #include "UARTlib.h" #include "CSlib.h" //Defining UART registers #define UCA0CTLW0 (*(unsigned volatile short *)0x40001000) #define UCA0CTLW1 (*(unsigned volatile short *)0x40001002) #define UCA0BRW (*(unsigned volatile short *)0x40001006) #define UCA0MCTLW (*(unsigned volatile short *)0x40001008) #define UCA0STATW (*(unsigned volatile char *)0x4000100a) #define UCA0RXBUF (*(unsigned volatile char *)0x4000100c) #define UCA0TXBUF (*(unsigned volatile char *)0x4000100e) #define UCA0IE (*(unsigned volatile short *)0x4000101a) #define UCA0IFG (*(unsigned volatile short *)0x4000101c) #define UCA0IV (*(unsigned volatile short *)0x4000101e) //Defining UART I/O pins registers #define P1DIR (*(unsigned volatile char *)0x40004C04) #define P1SEL0 (*(unsigned volatile char *)0x40004C0a) #define P1SEL1 (*(unsigned volatile char *)0x40004C0c) //Defining NVIC registers #define ISER0 (*(unsigned volatile long *)0xe000e100) #define IPR4 (*(unsigned volatile long *)0xe000e410) void global_int_on_off(unsigned int swtch); int UART_on(unsigned int speed, unsigned int parity){ struct mod_table { float min_val; int mod_val; } UCBRSx_vals[]={ {0, 0}, {0.0529, 0x1}, {0.0715, 0x2}, {0.0835, 0x4}, {0.1001, 0x8}, {0.1252, 0x10}, {0.1430, 0x20}, {0.1670, 0x11}, {0.2147, 0x21}, {0.2224, 0x22}, {0.2503, 0x44}, {0.3000, 0x25}, {0.3335, 0x49}, {0.3575, 0x4a}, {0.3753, 0x52}, {0.4003, 0x92}, {0.4286, 0x53}, {0.4378, 0x55}, {0.5002, 0xaa}, {0.5715, 0x6b}, {0.6003, 0xad}, {0.6254, 0xb5}, {0.6432, 0xb6}, {0.6667, 0xd6}, {0.7001, 0xb7}, {0.7147, 0xbb}, {0.7503, 0xdd}, {0.7861, 0xed}, {0.8004, 0xee}, {0.8333, 0xbf}, {0.8464, 0xdf}, {0.8572, 0xef}, {0.8751, 0xf7}, {0.9004, 0xfb}, {0.9170, 0xfd}, {0.9288, 0xfe} }; static float n; static int baud_int; float baud_frac_fl; static int baud_frac_int; static int i; i=35; n=CS_get_SMCLK_freq(); baud_int=0; baud_frac_int=0; baud_frac_fl=0; if(parity>1){ return ERROR; } asm( " MOV R0, #1\n" " MSR PRIMASK, R0\n" " MOV R0, #1\n" " MSR CONTROL, R0\n"); UCA0CTLW0|=UCSWRST; //stopping UART P1DIR=(P1DIR&~0xc)|(0x8); //Setiing up pins P1.2&3 for UART operation P1SEL1&=(~0xc); P1SEL0=(P1SEL0&~0xc)|(0xc); UCA0CTLW0=UCA0CTLW0&~(0xfffe); //Crearing all settings UCA0CTLW0|=((1 =0){ if(baud_frac_fl<UCBRSx_vals[i].min_val){ i--; }else break; } baud_frac_int=(int)(((n-baud_int)*16)+0.5); // making fractional part in accord with 1/16 fixed point UCA0MCTLW=1; //nulling modulation register and enabling oversampling mode UCA0MCTLW|=((baud_frac_int<<4)+(UCBRSx_vals[i].mod_val<<8)); //Writing the first and second modulation values; UCA0BRW=baud_int; //Loading int part UCA0IE=3; //receive and transmit interrupts enable ISER0|=(1<<16); //Activating UART0 interrupt IPR4|=3; //and setting priority global_int_on_off(1); //Switching on interrupts UCA0CTLW0&=(~UCSWRST); //Releasing UART return SUCCESS; }
↧