Skip to content

Keil编译环境下使用定时器1作为串口波特率发生器报错 #12

Description

@perseverance51

在uart1_timer1_tx.c文件中原外部变量引入:

extern __CODE uint16_t ticks_ms; extern __CODE uint8_t ticks_us, clkdiv;

需要如下修改:
`
#if defined (SDCC) || defined (__SDCC)
extern __CODE uint16_t ticks_ms;
extern __CODE uint8_t ticks_us; //clkdiv (include fw_reg_stc8h.h)
#elif defined CX51
extern uint16_t code ticks_ms;
extern uint8_t code ticks_us;
#endif

……

UART1_TxHex(CLKDIV);//改成大写

fw_sys.c文件中调整如下:
#if defined (SDCC) || defined (__SDCC)
__CODE uint16_t ticks_ms = (__CONF_FOSC / ((__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV) / __CLK_REF);
__CODE uint8_t ticks_us = (__CONF_FOSC / ((__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV) / __CLK_REF / 1000);
#elif defined CX51
uint16_t code ticks_ms = (__CONF_FOSC / ((__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV) / __CLK_REF);
uint8_t code ticks_us = (__CONF_FOSC / ((__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV) / __CLK_REF / 1000);
#endif
`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions