STM8s使用STVD编译时出现的奇葩问题,哪位大神解答一下
[复制链接]
问题如标题所述,问题出现在stm8_interrupt_vector.c中,将相同的代码与变量移到main.c中则没有问题。太奇怪了!
出现的错误提示如下:
#error clnk Debug\123.lkf:1 symbol c_idiv not defined (Debug\stm8_interrupt_vector.o )
#error clnk Debug\123.lkf:1 symbol c_sdivx not defined (Debug\stm8_interrupt_vector.o )
The command: "clnk -m Debug\123.map -l"D:\Program Files\Cosmic\Lib" -o Debug\123.sm8 Debug\123.lkf " has failed, the returned value is: 1
exit code=1.
错误提示貌似和除法命令有关,所以我就把代码中的除法换成了加法,结果居然编译通过!好奇怪。本人初学者。
stm8_interrupt_vector.c文件中的代码如下:
#include "stm8s903k3.h"
unsigned char rx_buffer[21];//接收缓存
unsigned char RSSI_value;//RSSI寄存器中的值
signed int RSSI_dBm = 0;//接收信号的强度
signed int RSSI_sum = 0; //3次的RSSI_dBm和
signed int RSSI_ave;//3次的RSSI_dBm的平均值
signed int RSSI_buffer[3];//最近三次的RSSI_dBm值
typedef void @far (*interrupt_handler_t)(void);
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
@far @Interrupt void NonHandledInterrupt (void)
{
/* in order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction
*/
return;
}
extern void _stext(); /* startup routine */
extern @far @interrupt void EXTI2_Interrupt(void);
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, EXTI2_Interrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, NonHandledInterrupt}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, NonHandledInterrupt}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};
extern @far @interrupt void EXTI2_Interrupt(void)
{
unsigned char i,j,k;
_asm("sim");
RSSI_ave = rx_buffer[19];
if(RSSI_value>=128) //AGC控制
{
RSSI_dBm =( RSSI_value-256)/2-72;
}
else
{
RSSI_dBm = RSSI_value/2-72;
}
for(i=0;i<2;i++)
{
RSSI_buffer = RSSI_buffer[i+1];
}
RSSI_buffer[2] = RSSI_dBm;
k = 0;
RSSI_sum = 0;
for(j=0;j<3;j++)
{
if(RSSI_buffer[j])
{
RSSI_sum += RSSI_buffer[j] ;
k++;
}
}
RSSI_ave = RSSI_sum/k;
_asm("rim");
return;
}