打印
[STM8]

STM8S208R8与STM8S208C8是否完全兼容

[复制链接]
2316|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhzzh18|  楼主 | 2015-6-5 18:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM8S208R8与STM8S208C8是否完全兼容,我用STM8S208C8(48pin)替换STM8S208R8(64PIN),代码一样,在R8上跑没问题,在C8上跑不起来,调试,发现在PORTC。4初始化出现异常,程序无法进行。
沙发
mmuuss586| | 2015-6-5 18:11 | 只看该作者
重新设置下,编译环境;

使用特权

评论回复
板凳
周董| | 2015-6-5 22:19 | 只看该作者
这个估计是和编译环境有关系的。。

使用特权

评论回复
地板
zhzzh18|  楼主 | 2015-6-6 11:21 | 只看该作者
开始我是用STM8S208R8,代码运行得好好的,现在打算用STM8208C8,代码也是一样的,都是用GPIOC.4,编译时MCU改成STM8208C8,重新编译,发现无法运行,用ST-LINK调试,发现在下面这个位置处问题
代码:
初始化GPIOC.4
    GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUT_PP_HIGH_SLOW;//GPIO_MODE_OUT_PP_HIGH_FAST;
    GPIO_InitStructure.GPIO_Pin = GPIO_PC4;
    GPIO_Init(GPIOC, &GPIO_InitStructure);

出错位置: GPIO_Init函数里的GPIOx->CR1 |= GPIO_InitStruct->GPIO_Pin;

void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Init_TypeDef* GPIO_InitStruct)
{

  /*----------------------*/
  /* Check the parameters */
  /*----------------------*/

        assert_param(IS_GPIO_MODE_OK(GPIO_InitStruct->GPIO_Mode));
        assert_param(IS_GPIO_PIN_OK(GPIO_InitStruct->GPIO_Pin));

  /*-----------------------------*/
  /* Input/Output mode selection */
  /*-----------------------------*/

        if ((((u8)(GPIO_InitStruct->GPIO_Mode)) & (u8)0x80) != (u8)0x00) /* Output mode */
        {
                if ((((u8)(GPIO_InitStruct->GPIO_Mode)) & (u8)0x10) != (u8)0x00) /* High level */
                {
                        GPIOx->ODR |= GPIO_InitStruct->GPIO_Pin;
                }
                else /* Low level */
                {
                        GPIOx->ODR &= (u8)(~(GPIO_InitStruct->GPIO_Pin));
                }
    /* Set Output mode */
                GPIOx->DDR |= GPIO_InitStruct->GPIO_Pin;
        }
        else /* Input mode */
        {
        /* Set Input mode */
                GPIOx->DDR &= (u8)(~(GPIO_InitStruct->GPIO_Pin));
        }

  /*------------------------------------------------------------------------*/
  /* Pull-Up/Float (Input) or Push-Pull/Open-Drain (Output) modes selection */
  /*------------------------------------------------------------------------*/

        if ((((u8)(GPIO_InitStruct->GPIO_Mode)) & (u8)0x40) != (u8)0x00) /* Pull-Up or Push-Pull */
        {
                GPIOx->CR1 |= GPIO_InitStruct->GPIO_Pin;
        }
        else /* Float or Open-Drain */
        {
                GPIOx->CR1 &= (u8)(~(GPIO_InitStruct->GPIO_Pin));
        }

  /*-----------------------------------------------------*/
  /* Interrupt (Input) or Slope (Output) modes selection */
  /*-----------------------------------------------------*/

        if ((((u8)(GPIO_InitStruct->GPIO_Mode)) & (u8)0x20) != (u8)0x00) /* Interrupt or Slow slope */
        {
                GPIOx->CR2 |= GPIO_InitStruct->GPIO_Pin;
        }
        else /* No external interrupt or No slope control */
        {
                GPIOx->CR2 &= (u8)(~(GPIO_InitStruct->GPIO_Pin));
        }

}
出错提示:
Error:gdi-error[40127]:flash memory not accessible while core is running

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

34

帖子

1

粉丝