关于控制寄存器输出问题

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ViSh_3577471
Level 2
Level 2
10 replies posted 5 replies posted 10 questions asked

您好,

          我想用控制寄存器控制IO输出,使用了Control_Reg_1_Write()函数,并通过Cy_GPIO_Read()读取IO口电平变化,但结果通过UART串口助手查看控制寄存器中d0,d1,d2的IO电平值,发现写到Control_Reg_1_Write()的值无法控制IO口变化,printf结果都为1(IO口初始设置为Strong Drive,high(1)  )?

代码:

int main(void)

{

      __enable_irq(); /* Enable global interrupts. */

    uint8_t i=0;

    uint8_t j=0;

    uint8_t k=0;

    setvbuf(stdin,0,_IONBF,0);

    UART_1_Start();

    Control_Reg_1_Write(ox00);

    i=Cy_GPIO_ReadOut(GPIO_PRT9,0u);//d0

    j=Cy_GPIO_ReadOut(GPIO_PRT9,1u);//d1

    k=Cy_GPIO_ReadOut(GPIO_PRT9,2u);//d3

    printf("\ni=%d\n",i);

    printf("\nj=%d\n",j);

    printf("\nk=%d\n",k);

     for(;;)

    {   /* Place your application code here. */

    }

}

pastedImage_0.png

pastedImage_1.png

0 点赞
1 解答
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

请使能你引脚的digital input. 具体的配置见附件。 这样我测试过了,是可以通过control register 控制GPIO的输出,并且可以通过API 正常读入GPIO的状态。 希望我的回复可以对你有所帮助。

pastedImage_0.png

在原帖中查看解决方案

0 点赞
1 回复
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

请使能你引脚的digital input. 具体的配置见附件。 这样我测试过了,是可以通过control register 控制GPIO的输出,并且可以通过API 正常读入GPIO的状态。 希望我的回复可以对你有所帮助。

pastedImage_0.png

0 点赞