First of all, I use arm cm3 core chips and the function of my codes is Shift operation. For example, UART receive “f0”, save “0f” to the corresponding address. Codes are below.
void UARTRXHandler(void) {
volatile uint32_t *ramstoreaddr = RAM_START_ADDR ;
unsigned char rxchar;
uint32_t ch;
if (uart_GetRxIRQStatus(UART) != 0) { // 检查接收中断状态 Check the receiving interrupt status
rxchar = uart_ReceiveChar(UART); // 从 UART 接收字符 Receives characters from UART
uart_ClearRxIRQ(UART); // 清除接收中断标志 Clear the receive interrupt flag
ch = ((rxchar & 0x0F) << 4 ) | ((rxchar & 0xF0) >> 4 );
*ramstoreaddr = ch; // 存储字符到内存 Stores characters to memory
ramstoreaddr++;
}
This is my interrupt function when i receive rxd’s data. In theory, when rxd’s data comes, it will jump into interrupt function, and “ramstoreaddr” won’t change .
By the way , RAM_START_ADDR is also defined in another header file.
#define RAM_START_ADDR (volatile uint32_t *)0x21001000
When rxd sends “0f” then “1f” “2f” “3f”, address still remain at 0x21001000.(you can see it in pictures)
rxd comes from testbench it can correctly send “0f””1f” “2f” “3f”.
this is signals in ram
address remain 0x21001000 first pic you can see 1000 in ADDR which refers to 0x21001000
address remain 0x21001000 second pic
address remain 0x21001000 third pic
I try to make declaration and initialization out of the function in the same c file like this:
volatile uint32_t *ramstoreaddr = RAM_START_ADDR ;
void UARTRXHandler(void) {
unsigned char rxchar;
uint32_t ch;
if (uart_GetRxIRQStatus(UART) != 0) { // 检查接收中断状态 Check the receiving interrupt status
rxchar = uart_ReceiveChar(UART); // 从 UART 接收字符 Receives characters from UART
uart_ClearRxIRQ(UART); // 清除接收中断标志 Clear the receive interrupt flag
ch = ((rxchar & 0x0F) << 4 ) | ((rxchar & 0xF0) >> 4 );
*ramstoreaddr = ch; // 存储字符到内存 Stores characters to memory
ramstoreaddr++;
}
The result turns like this in pictures , it didn’t process in a right way.
wrong write f you can see in picture and compare it with pictures above, after HWDATA’s “f” , it turns to 0 and HADDR is 4, which it suppose to write in 0x21001000(1000 in HADDR )
wrong write 1f
And it change address to another one which I never set.