TI中文支持网
TI专业的中文技术问题搜集分享网站

F28335 串口中断接收和发送数据一起进行,一分钟后发送数据正常,无法接收数据。

采用无FIFO中断模式

波特率: 115200

f28335 to PC :每500ms发送12字节数据

PC to f28335: 每10ms发送12字节数据

开始时f28335发送和接收正常,一分钟后28335无法接收数据,发送正常。

谁遇到过同样的问题谢谢。

void scib_fifo_init(void)
{

ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCIHBAUD = 0;
ScibRegs.SCILBAUD = 39;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
ScibRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
ScibRegs.SCICTL1.bit.SWRESET = 1;
}

// Connected to PIEIER9_3 (use MINT9 and MG93 masks):
#if (G93PL != 0)
interrupt void SCIRXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….
Uint8 rcvdat;
rcvdat = ScibRegs.SCIRXBUF.all;
if(state_machine == 0) 
{
if(rcvdat == 'A') 
{
state_machine = 1;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 1)
{
if(rcvdat == 'A') 
{
state_machine = 2;
}
else
{
state_machine = 0; 
}

}
else if(state_machine == 2)
{
if(rcvdat == 'B') 
{
state_machine = 3;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 3)
{
if(rcvdat == 'B') 
{
state_machine = 4;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 4)
{
if(j<3)
{
DatLen =(DatLen|rcvdat)<<8;
j++;
}
else
{
j=0;
DatLen =DatLen|rcvdat;
state_machine=5;
}
}
else if(state_machine == 5)
{
FuncID = rcvdat;
state_machine = 6;
}
else if(state_machine == 6)
{
if(i<(DatLen-2))
{
RDATA[i] = rcvdat;
i++;
}
else
{
RDATA[i] = rcvdat;
state_machine = 7;
i = 0 ;
}
}
else if(state_machine == 7)
{
if(rcvdat == 'C') 
{
state_machine = 8;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 8)
{
if(rcvdat == 'C') 
{
state_machine = 9;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 9)
{
if(rcvdat == 'D') 
{
state_machine = 10;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 10)
{
if(rcvdat == 'D') 
{
state_machine = 0 ;
UcStatus = 1;
}
else
{
state_machine = 0 ;
}

}

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

// Connected to PIEIER9_4 (use MINT9 and MG94 masks):
#if (G94PL != 0)
interrupt void SCITXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

rookiecalf:

不正常的时候,查看各寄存器的状态有无异常

采用无FIFO中断模式

波特率: 115200

f28335 to PC :每500ms发送12字节数据

PC to f28335: 每10ms发送12字节数据

开始时f28335发送和接收正常,一分钟后28335无法接收数据,发送正常。

谁遇到过同样的问题谢谢。

void scib_fifo_init(void)
{

ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCIHBAUD = 0;
ScibRegs.SCILBAUD = 39;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
ScibRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
ScibRegs.SCICTL1.bit.SWRESET = 1;
}

// Connected to PIEIER9_3 (use MINT9 and MG93 masks):
#if (G93PL != 0)
interrupt void SCIRXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….
Uint8 rcvdat;
rcvdat = ScibRegs.SCIRXBUF.all;
if(state_machine == 0) 
{
if(rcvdat == 'A') 
{
state_machine = 1;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 1)
{
if(rcvdat == 'A') 
{
state_machine = 2;
}
else
{
state_machine = 0; 
}

}
else if(state_machine == 2)
{
if(rcvdat == 'B') 
{
state_machine = 3;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 3)
{
if(rcvdat == 'B') 
{
state_machine = 4;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 4)
{
if(j<3)
{
DatLen =(DatLen|rcvdat)<<8;
j++;
}
else
{
j=0;
DatLen =DatLen|rcvdat;
state_machine=5;
}
}
else if(state_machine == 5)
{
FuncID = rcvdat;
state_machine = 6;
}
else if(state_machine == 6)
{
if(i<(DatLen-2))
{
RDATA[i] = rcvdat;
i++;
}
else
{
RDATA[i] = rcvdat;
state_machine = 7;
i = 0 ;
}
}
else if(state_machine == 7)
{
if(rcvdat == 'C') 
{
state_machine = 8;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 8)
{
if(rcvdat == 'C') 
{
state_machine = 9;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 9)
{
if(rcvdat == 'D') 
{
state_machine = 10;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 10)
{
if(rcvdat == 'D') 
{
state_machine = 0 ;
UcStatus = 1;
}
else
{
state_machine = 0 ;
}

}

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

// Connected to PIEIER9_4 (use MINT9 and MG94 masks):
#if (G94PL != 0)
interrupt void SCITXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

youqi lu:

回复 rookiecalf:

我也遇见同样问题(波特率115200)  出错时SCIRXST=0x00B2  我目前的解决办法是检测SCIRXSTbit7为1时重启SCI, 请问是什么原因导致的,或者有更好的解决办法没?

采用无FIFO中断模式

波特率: 115200

f28335 to PC :每500ms发送12字节数据

PC to f28335: 每10ms发送12字节数据

开始时f28335发送和接收正常,一分钟后28335无法接收数据,发送正常。

谁遇到过同样的问题谢谢。

void scib_fifo_init(void)
{

ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCIHBAUD = 0;
ScibRegs.SCILBAUD = 39;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
ScibRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
ScibRegs.SCICTL1.bit.SWRESET = 1;
}

// Connected to PIEIER9_3 (use MINT9 and MG93 masks):
#if (G93PL != 0)
interrupt void SCIRXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….
Uint8 rcvdat;
rcvdat = ScibRegs.SCIRXBUF.all;
if(state_machine == 0) 
{
if(rcvdat == 'A') 
{
state_machine = 1;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 1)
{
if(rcvdat == 'A') 
{
state_machine = 2;
}
else
{
state_machine = 0; 
}

}
else if(state_machine == 2)
{
if(rcvdat == 'B') 
{
state_machine = 3;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 3)
{
if(rcvdat == 'B') 
{
state_machine = 4;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 4)
{
if(j<3)
{
DatLen =(DatLen|rcvdat)<<8;
j++;
}
else
{
j=0;
DatLen =DatLen|rcvdat;
state_machine=5;
}
}
else if(state_machine == 5)
{
FuncID = rcvdat;
state_machine = 6;
}
else if(state_machine == 6)
{
if(i<(DatLen-2))
{
RDATA[i] = rcvdat;
i++;
}
else
{
RDATA[i] = rcvdat;
state_machine = 7;
i = 0 ;
}
}
else if(state_machine == 7)
{
if(rcvdat == 'C') 
{
state_machine = 8;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 8)
{
if(rcvdat == 'C') 
{
state_machine = 9;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 9)
{
if(rcvdat == 'D') 
{
state_machine = 10;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 10)
{
if(rcvdat == 'D') 
{
state_machine = 0 ;
UcStatus = 1;
}
else
{
state_machine = 0 ;
}

}

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

// Connected to PIEIER9_4 (use MINT9 and MG94 masks):
#if (G94PL != 0)
interrupt void SCITXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

Huihong LIU1:

应该是波特率设置错误,115200,计算出来时39,对应16进制数应该是0x0027。改改试试看

采用无FIFO中断模式

波特率: 115200

f28335 to PC :每500ms发送12字节数据

PC to f28335: 每10ms发送12字节数据

开始时f28335发送和接收正常,一分钟后28335无法接收数据,发送正常。

谁遇到过同样的问题谢谢。

void scib_fifo_init(void)
{

ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCIHBAUD = 0;
ScibRegs.SCILBAUD = 39;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
ScibRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
ScibRegs.SCICTL1.bit.SWRESET = 1;
}

// Connected to PIEIER9_3 (use MINT9 and MG93 masks):
#if (G93PL != 0)
interrupt void SCIRXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….
Uint8 rcvdat;
rcvdat = ScibRegs.SCIRXBUF.all;
if(state_machine == 0) 
{
if(rcvdat == 'A') 
{
state_machine = 1;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 1)
{
if(rcvdat == 'A') 
{
state_machine = 2;
}
else
{
state_machine = 0; 
}

}
else if(state_machine == 2)
{
if(rcvdat == 'B') 
{
state_machine = 3;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 3)
{
if(rcvdat == 'B') 
{
state_machine = 4;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 4)
{
if(j<3)
{
DatLen =(DatLen|rcvdat)<<8;
j++;
}
else
{
j=0;
DatLen =DatLen|rcvdat;
state_machine=5;
}
}
else if(state_machine == 5)
{
FuncID = rcvdat;
state_machine = 6;
}
else if(state_machine == 6)
{
if(i<(DatLen-2))
{
RDATA[i] = rcvdat;
i++;
}
else
{
RDATA[i] = rcvdat;
state_machine = 7;
i = 0 ;
}
}
else if(state_machine == 7)
{
if(rcvdat == 'C') 
{
state_machine = 8;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 8)
{
if(rcvdat == 'C') 
{
state_machine = 9;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 9)
{
if(rcvdat == 'D') 
{
state_machine = 10;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 10)
{
if(rcvdat == 'D') 
{
state_machine = 0 ;
UcStatus = 1;
}
else
{
state_machine = 0 ;
}

}

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

// Connected to PIEIER9_4 (use MINT9 and MG94 masks):
#if (G94PL != 0)
interrupt void SCITXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

peng chen9:

回复 youqi lu:

我也没有解决方案,我检测到重启SCI没有效果,我实在发送中断里检测然后重启。要在主循环中检测重启吗。

采用无FIFO中断模式

波特率: 115200

f28335 to PC :每500ms发送12字节数据

PC to f28335: 每10ms发送12字节数据

开始时f28335发送和接收正常,一分钟后28335无法接收数据,发送正常。

谁遇到过同样的问题谢谢。

void scib_fifo_init(void)
{

ScibRegs.SCICCR.all =0x0007;
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCIHBAUD = 0;
ScibRegs.SCILBAUD = 39;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
ScibRegs.SCICTL1.bit.TXENA = 1; // SCI transmitter enable
ScibRegs.SCICTL1.bit.RXENA = 1; // SCI receiver enable
ScibRegs.SCICTL1.bit.SWRESET = 1;
}

// Connected to PIEIER9_3 (use MINT9 and MG93 masks):
#if (G93PL != 0)
interrupt void SCIRXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG93; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….
Uint8 rcvdat;
rcvdat = ScibRegs.SCIRXBUF.all;
if(state_machine == 0) 
{
if(rcvdat == 'A') 
{
state_machine = 1;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 1)
{
if(rcvdat == 'A') 
{
state_machine = 2;
}
else
{
state_machine = 0; 
}

}
else if(state_machine == 2)
{
if(rcvdat == 'B') 
{
state_machine = 3;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 3)
{
if(rcvdat == 'B') 
{
state_machine = 4;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 4)
{
if(j<3)
{
DatLen =(DatLen|rcvdat)<<8;
j++;
}
else
{
j=0;
DatLen =DatLen|rcvdat;
state_machine=5;
}
}
else if(state_machine == 5)
{
FuncID = rcvdat;
state_machine = 6;
}
else if(state_machine == 6)
{
if(i<(DatLen-2))
{
RDATA[i] = rcvdat;
i++;
}
else
{
RDATA[i] = rcvdat;
state_machine = 7;
i = 0 ;
}
}
else if(state_machine == 7)
{
if(rcvdat == 'C') 
{
state_machine = 8;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 8)
{
if(rcvdat == 'C') 
{
state_machine = 9;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 9)
{
if(rcvdat == 'D') 
{
state_machine = 10;
}
else
{
state_machine = 0; 
}
}
else if(state_machine == 10)
{
if(rcvdat == 'D') 
{
state_machine = 0 ;
UcStatus = 1;
}
else
{
state_machine = 0 ;
}

}

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

// Connected to PIEIER9_4 (use MINT9 and MG94 masks):
#if (G94PL != 0)
interrupt void SCITXINTB_ISR(void) // SCI-B
{
// Set interrupt priority:
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER9.all;
IER |= M_INT9;
IER &= MINT9; // Set "global" priority
PieCtrlRegs.PIEIER9.all &= MG94; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;

// Insert ISR Code here…….

// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;

// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);

}
#endif

summer xu:

兄弟,串口处理的代码时间越短越好,因为接受一个字符都会进入一次中断的。你的状态机全是if else,每次都会重复判断很多无用分支,很浪费时间的。应该采用switch case代替if else,因为switch case的话每次只匹配有效分支,无用的分支是直接忽略掉的!

赞(0)
未经允许不得转载:TI中文支持网 » F28335 串口中断接收和发送数据一起进行,一分钟后发送数据正常,无法接收数据。
分享到: 更多 (0)