[开发工具] STM8的COSMIC8編譯器問題

[复制链接]
 楼主| eng588 发表于 2009-7-15 10:43 | 显示全部楼层 |阅读模式
COSMIC手冊說:中斷函數必須用@near修飾,但是生成的中斷文件里卻將向量定義成一個指向@far的指針????


以下是COSMIC手冊:
The STM8 architecture forces any interrupt function to be located in the
first 64K. The interrupt vector table containing 2-byte addresses, interrupt
functions declared in C must be declared with the @near modifier
if the vector table is also written in C.


以下是COSMIC自動生成的中斷文件:

/*    BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
 *    Copyright (c) 2007 STMicroelectronics
 */

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 */

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, NonHandledInterrupt}, /* 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 */
};
 楼主| eng588 发表于 2009-7-16 09:19 | 显示全部楼层

沒有人知道嗎?

如題
汉之云 发表于 2009-7-16 09:55 | 显示全部楼层

手册的名称和版本号是什么?

COSMIC STM8现在最新的好像是4.2.10,在 < C Cross Compiler User’s Guide
for ST Microelectronics STM8 > 里没查到
"The STM8 architecture forces any interrupt function to be located in the first 64K. The interrupt vector table containing 2-byte addresses, interrupt functions declared in C must be declared with the @near modifier if the vector table is also written in C."

在STM8的reference manual里也不曾见过这种说法.

此外这个观点是错误的,STM8的中断完全可以定位到0x10000以后,你试一下就知道了.

 楼主| eng588 发表于 2009-7-17 10:10 | 显示全部楼层

CXSTM8_UsersGuide

名稱:CXSTM8_UsersGuide.pdf,安裝完編譯器后,版本4.2,弟57頁:write a interrupt hands.  見文檔。
相关链接:http://bbs.21ic.com/upfiles/img/20097/200971710533189.zip
汉之云 发表于 2009-7-17 10:29 | 显示全部楼层

这个文档out了

我装的cosmic 也有这个文件,版本也是4.2,不过这一段已经被去掉了.建议你装个最新的版本吧.
汉之云 发表于 2009-7-17 11:45 | 显示全部楼层

最新版显然是去cosmic网站去download

sjh03 发表于 2009-7-17 16:13 | 显示全部楼层

你完全可以用如下方法做,不用考虑@far 或 @near。

#define NULL 0

extern void _stext();        /* startup routine */


void (* const @vector _vectab[32])() = {
    _stext,            /* RESET       */
    NULL,            /* TRAP        */
    NULL,            /* TLI         */
    NULL,            /* AWU         */
    NULL,            /* CLK         */
    NULL,            /* EXTI PORTA  */
    NULL,            /* EXTI PORTB  */
    NULL,            /* EXTI PORTC  */
    NULL,            /* EXTI PORTD  */
    NULL,            /* EXTI PORTE  */
    NULL,            /* CAN RX      */
    NULL,            /* CAN TX      */
    NULL,            /* SPI         */
    NULL,            /* TIMER 1 OVF */
    NULL,            /* TIMER 1 CAP */
    NULL,            /* TIMER 2 OVF */
    NULL,            /* TIMER 2 CAP */
    NULL,            /* TIMER 3 OVF */
    NULL,            /* TIMER 3 CAP */
    NULL,            /* USART TX    */
    NULL,            /* USART RX    */
    NULL,            /* I2C         */
    NULL,            /* LINUART TX  */
    NULL,            /* LINUART RX  */
    NULL,            /* ADC         */
    NULL,            /* TIMER 4 OVF */
    NULL,            /* EEPROM ECC  */
    NULL,            /* Reserved    */
    NULL,            /* Reserved    */
    NULL,            /* Reserved    */
    NULL,            /* Reserved    */
    NULL,            /* Reserved    */
    };
 楼主| eng588 发表于 2009-7-24 15:03 | 显示全部楼层

這個方法好

這個方法好
菩堤树下 发表于 2014-9-25 16:19 | 显示全部楼层
求:Cxstm8_16K或Cxstm8_32K编译软件;请发QQ:229488361@qq.com;谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

82

主题

179

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部

82

主题

179

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部