今天在操作GPIO的时候,进行了如下操作:
for(;;)
{
GpioDataRegs.GPCDAT.bit.GPIO64 = 0;
GpioDataRegs.GPCDAT.bit.GPIO65 = 0;
delay_loop();
GpioDataRegs.GPCDAT.bit.GPIO64 = 1;
GpioDataRegs.GPCDAT.bit.GPIO65 = 1;
delay_loop();
}
即通过GPCDAT的bit位改变GPIO状态,发现操作失败,
现象是GPIO64不能实现状态改变,GPIO65可以实现状态改变。
后在“TMS320x2833x, 2823x System Control and Interrupts Reference Guide”中找到如下解释:
When using the GPxDAT register to change the level of an output pin, you should be cautious not to
accidentally change the level of another pin. For example, if you mean to change the output latch level
of GPIOA0 by writing to the GPADAT register bit 0, using a read-modify-write instruction. The problem
can occur if another I/O port A signal changes level between the read and the write stage of the
instruction. You can also change the state of that output latch. You can avoid this scenario by using
the GPxSET, GPxCLEAR, and GPxTOGGLE registers to load the output latch instead.
大家帮忙看下是不是这个原因导致的。
试了以下操作,都是可以正常实现IO状态的改变
for(;;) //一次性赋值
{ GpioDataRegs.GPCDAT.all = 0x00000000;
delay_loop();
GpioDataRegs.GPCDAT.all = 0x00000003;
delay_loop();
}
or
for(;;) //SET CLEAR操作
{ GpioDataRegs.GPCCLEAR.bit.GPIO64 = 1;
GpioDataRegs.GPCCLEAR.bit.GPIO65 = 1;
delay_loop();
GpioDataRegs.GPCSET.bit.GPIO64 = 1;
GpioDataRegs.GPCSET.bit.GPIO65 = 1;
delay_loop();
}
Joey Mao:
是的,对TMS320x2833x, 2823x的某一个GPIO进行置1清零操作,不建议直接对其DAT数据寄存器进行赋值,而是建议使用SET、CLEAR或TOGGLE来完成
今天在操作GPIO的时候,进行了如下操作:
for(;;)
{
GpioDataRegs.GPCDAT.bit.GPIO64 = 0;
GpioDataRegs.GPCDAT.bit.GPIO65 = 0;
delay_loop();
GpioDataRegs.GPCDAT.bit.GPIO64 = 1;
GpioDataRegs.GPCDAT.bit.GPIO65 = 1;
delay_loop();
}
即通过GPCDAT的bit位改变GPIO状态,发现操作失败,
现象是GPIO64不能实现状态改变,GPIO65可以实现状态改变。
后在“TMS320x2833x, 2823x System Control and Interrupts Reference Guide”中找到如下解释:
When using the GPxDAT register to change the level of an output pin, you should be cautious not to
accidentally change the level of another pin. For example, if you mean to change the output latch level
of GPIOA0 by writing to the GPADAT register bit 0, using a read-modify-write instruction. The problem
can occur if another I/O port A signal changes level between the read and the write stage of the
instruction. You can also change the state of that output latch. You can avoid this scenario by using
the GPxSET, GPxCLEAR, and GPxTOGGLE registers to load the output latch instead.
大家帮忙看下是不是这个原因导致的。
试了以下操作,都是可以正常实现IO状态的改变
for(;;) //一次性赋值
{ GpioDataRegs.GPCDAT.all = 0x00000000;
delay_loop();
GpioDataRegs.GPCDAT.all = 0x00000003;
delay_loop();
}
or
for(;;) //SET CLEAR操作
{ GpioDataRegs.GPCCLEAR.bit.GPIO64 = 1;
GpioDataRegs.GPCCLEAR.bit.GPIO65 = 1;
delay_loop();
GpioDataRegs.GPCSET.bit.GPIO64 = 1;
GpioDataRegs.GPCSET.bit.GPIO65 = 1;
delay_loop();
}
mangui zhang:
一次性赋值为什么可以 不怎么理解
今天在操作GPIO的时候,进行了如下操作:
for(;;)
{
GpioDataRegs.GPCDAT.bit.GPIO64 = 0;
GpioDataRegs.GPCDAT.bit.GPIO65 = 0;
delay_loop();
GpioDataRegs.GPCDAT.bit.GPIO64 = 1;
GpioDataRegs.GPCDAT.bit.GPIO65 = 1;
delay_loop();
}
即通过GPCDAT的bit位改变GPIO状态,发现操作失败,
现象是GPIO64不能实现状态改变,GPIO65可以实现状态改变。
后在“TMS320x2833x, 2823x System Control and Interrupts Reference Guide”中找到如下解释:
When using the GPxDAT register to change the level of an output pin, you should be cautious not to
accidentally change the level of another pin. For example, if you mean to change the output latch level
of GPIOA0 by writing to the GPADAT register bit 0, using a read-modify-write instruction. The problem
can occur if another I/O port A signal changes level between the read and the write stage of the
instruction. You can also change the state of that output latch. You can avoid this scenario by using
the GPxSET, GPxCLEAR, and GPxTOGGLE registers to load the output latch instead.
大家帮忙看下是不是这个原因导致的。
试了以下操作,都是可以正常实现IO状态的改变
for(;;) //一次性赋值
{ GpioDataRegs.GPCDAT.all = 0x00000000;
delay_loop();
GpioDataRegs.GPCDAT.all = 0x00000003;
delay_loop();
}
or
for(;;) //SET CLEAR操作
{ GpioDataRegs.GPCCLEAR.bit.GPIO64 = 1;
GpioDataRegs.GPCCLEAR.bit.GPIO65 = 1;
delay_loop();
GpioDataRegs.GPCSET.bit.GPIO64 = 1;
GpioDataRegs.GPCSET.bit.GPIO65 = 1;
delay_loop();
}
user78960159:
回复 Joey Mao:
好的 谢谢