为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
ZhangLi1:
谁告诉你这样写代码来发送串口数据的?
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
jian lu4:
回复 ZhangLi1:
老师这样说的,因为自己用发送中断函数的话不会设置,总是发不出
interrupt void sSciTxIsr(void) // SCI-A DELAY_US(100000);{
SciaRegs.SCITXBUF= Modbusbuf[SCITXCount]; if(++SCITXCount>LEN)SCITXCount=0; DSP28x_usDelay(500000);
SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flagPieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Issue PIE ACK}
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
ZhangLi1:
回复 jian lu4:
串口发送数据是需要时间的,你连续向发送寄存器写,硬塞它也发送不了啊。
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
jian lu4:
回复 ZhangLi1:
太感谢您了,给我说得那么详细,刚刚在循环语句后面设置了10ms的延时程序就能发送了,请问又该怎么解决发送和接收时间互相错开以免干扰的问题呢?
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
jian lu4:
回复 ZhangLi1:
请问在进入定时器中断程序后,RX端接收到数据,请问该怎么设置让程序自动进入接收中断呢?
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
jian lu4:
回复 ZhangLi1:
请问在进入定时器中断程序后,RX端接收到数据,请问该怎么设置让程序自动进入接收中断呢?
为什么我在定时器中断设置了一个循环发送语句,但是只发送数组的首位和末尾字节,中间的都发不出来
interrupt void cpu_timer0_isr(void)
{Uint16 i;
CpuTimer0.InterruptCount++;
for(i = 0; i<LEN; i++)
{
SciaRegs.SCITXBUF= Modbusbuf[i];
}
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 500 milliseconds GPIO34端口电平翻转一次
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Seven Han:
回复 jian lu4:
你好,请下载controlSUITE,可以参考sci例程。
http://www.ti.com.cn/tool/cn/CONTROLSUITE?keyMatch=controlSUITE&tisearch=Search-CN-Everything