1.?__attribute__((optimize("O0")));
?
"O0" 是代表优化等级,0是不优化,根基自己选则,在函数定义的前面加上?__attribute__((optimize("O0")))? 。就可以自己定义优化等级,而不是编译器的选项约束
?
?
?2. 开优化选项的时候,有的时候 会存在问题。
data_iq = data_i1 | data_q1;
*(uint32_t *)REG_RF_BRIGE_FIFO_ADDR = data_iq;
}
enable_pluse(); //start pluse,triger transmit
开优化,这行代码会执行有问题,.S 文件直接把 赋值 这句话 优化不见了,神奇了
data_iq = data_i1 | data_q1;
2538: e81f cf9b orhi r15, 0xf9b
253c: bf8e sw (r14+[0]), r15
enable_pluse(); //start pluse,triger transmit
?不开优化,这句话
data_iq = data_i1 | data_q1;
25e6: e040 a742 lw r14, (r2-[4])
25ea: e040 a7d2 lw r15, (r2-[5])
25ee: 3fce or r15, r15, r14
25f0: e040 bfe2 sw (r2-[6]), r15
*(uint32_t *)REG_RF_BRIGE_FIFO_ADDR = data_iq;
25f4: e000 1fb8 l r15, (gp+[56]) 0x40638 <_GLOBAL_OFFSET_TABLE_+0xe0>
25f8: e040 a762 lw r14, (r2-[6])
25fc: bf0f sw (r15+[0]), r14
for(i = 0; i < tx_count; i++) {
25fe: a782 lw r15, (r2+[0])
2600: c781 add r15, 1
2602: bf82 sw (r2+[0]), r15
2604: e040 9fc2 lhu r15, (r2-[4])
2608: e40f 37a0 sl r15, r15, 16
260c: e40f 37c0 sru r15, r15, 16
2610: a702 lw r14, (r2+[0])
2612: 3f7f cmp r14, r15
2614: e7ff 04aa blu 0x2568 <brige_tx_iq_tab+0x7a>
}
enable_pluse(); //start pluse,triger transmit
因为这句话,才出问题的肯定与这个REG_RF_BRIGE_FIFO_ADDR??有关
#define RF_BRIGE_BASE_ADDR (0x80000400+5*4) //5
#define REG_RF_BRIGE_FIFO_ADDR (RF_BRIGE_BASE_ADDR + 12) // 8
?改进之后,把 *(uint32_t *)REG_RF_BRIGE_FIFO_ADDR = data_iq;
#define REG_BLE_RD(addr) (*(volatile uint32_t *)(addr))
#define REG_BLE_WR(addr, value) (*(volatile uint32_t *)(addr)) = (value)
改成
REG_BLE_WR(REG_RF_BRIGE_FIFO_ADDR , data_iq)? ?;
|