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

打开ADC中断,会影响SPI吗?

我使用F28027。程序中使用SPI,只发送数据,用三条线:

SpiaRegs.SPICCR.all = 0x007; // 8-bit character, SPI reset
SpiaRegs.SPICTL.bit.OVERRUNINTENA = 1;
SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
SpiaRegs.SPICTL.bit.TALK = 1;
SpiaRegs.SPICTL.bit.SPIINTENA = 0;

SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
SpiaRegs.SPICCR.bit.SPICHAR = 7; // 8-bit character, nomal mode

SpiaRegs.SPISTS.all = 0x00E0; // Clear flag
SpiaRegs.SPIBRR = 0x05; // Baud rate, = LSPCLK /( SPIBRR + 1 ), iboudrate is 15MHz as BRR= 3
SpiaRegs.SPICCR.bit.SPISWRESET=1;
SpiaRegs.SPIPRI.all = 0x0011;

使用了ADC,用PWM触发:

AdcRegs.INTSEL1N2.bit.INT1E = 1; // enable
AdcRegs.INTSEL1N2.bit.INT1SEL = 3; // EOC3 is trigger for ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 1; // Enable ADCINT1 Continuous mode

ADC中断处理是使用汇编语言编写的。

当打开ADC中断后,就会一直停在这一句:

while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}

但把ADC中断关闭后,SPI发送正常。其发送程序是:

Uint16 WriteData(Uint16 Data)
{

Uint16 dummy;
A0SET_TO_DATA(); // GPIO17
dummy = SpiaRegs.SPIRXBUF;
SpiaRegs.SPITXBUF = Data << 8 ;
while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}
SpiaRegs.SPISTS.all = 0xFF;
dummy = SpiaRegs.SPITXBUF;

return dummy;
}

请大伙帮忙,看看问题到底出在哪里。谢谢大家

TX dong:

问题解决!

我使用F28027。程序中使用SPI,只发送数据,用三条线:

SpiaRegs.SPICCR.all = 0x007; // 8-bit character, SPI reset
SpiaRegs.SPICTL.bit.OVERRUNINTENA = 1;
SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
SpiaRegs.SPICTL.bit.TALK = 1;
SpiaRegs.SPICTL.bit.SPIINTENA = 0;

SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
SpiaRegs.SPICCR.bit.SPICHAR = 7; // 8-bit character, nomal mode

SpiaRegs.SPISTS.all = 0x00E0; // Clear flag
SpiaRegs.SPIBRR = 0x05; // Baud rate, = LSPCLK /( SPIBRR + 1 ), iboudrate is 15MHz as BRR= 3
SpiaRegs.SPICCR.bit.SPISWRESET=1;
SpiaRegs.SPIPRI.all = 0x0011;

使用了ADC,用PWM触发:

AdcRegs.INTSEL1N2.bit.INT1E = 1; // enable
AdcRegs.INTSEL1N2.bit.INT1SEL = 3; // EOC3 is trigger for ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 1; // Enable ADCINT1 Continuous mode

ADC中断处理是使用汇编语言编写的。

当打开ADC中断后,就会一直停在这一句:

while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}

但把ADC中断关闭后,SPI发送正常。其发送程序是:

Uint16 WriteData(Uint16 Data)
{

Uint16 dummy;
A0SET_TO_DATA(); // GPIO17
dummy = SpiaRegs.SPIRXBUF;
SpiaRegs.SPITXBUF = Data << 8 ;
while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}
SpiaRegs.SPISTS.all = 0xFF;
dummy = SpiaRegs.SPITXBUF;

return dummy;
}

请大伙帮忙,看看问题到底出在哪里。谢谢大家

Young Hu:

回复 TX dong:

二者不会有冲突。能否分享下如何解决的么

我使用F28027。程序中使用SPI,只发送数据,用三条线:

SpiaRegs.SPICCR.all = 0x007; // 8-bit character, SPI reset
SpiaRegs.SPICTL.bit.OVERRUNINTENA = 1;
SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
SpiaRegs.SPICTL.bit.TALK = 1;
SpiaRegs.SPICTL.bit.SPIINTENA = 0;

SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
SpiaRegs.SPICCR.bit.SPICHAR = 7; // 8-bit character, nomal mode

SpiaRegs.SPISTS.all = 0x00E0; // Clear flag
SpiaRegs.SPIBRR = 0x05; // Baud rate, = LSPCLK /( SPIBRR + 1 ), iboudrate is 15MHz as BRR= 3
SpiaRegs.SPICCR.bit.SPISWRESET=1;
SpiaRegs.SPIPRI.all = 0x0011;

使用了ADC,用PWM触发:

AdcRegs.INTSEL1N2.bit.INT1E = 1; // enable
AdcRegs.INTSEL1N2.bit.INT1SEL = 3; // EOC3 is trigger for ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 1; // Enable ADCINT1 Continuous mode

ADC中断处理是使用汇编语言编写的。

当打开ADC中断后,就会一直停在这一句:

while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}

但把ADC中断关闭后,SPI发送正常。其发送程序是:

Uint16 WriteData(Uint16 Data)
{

Uint16 dummy;
A0SET_TO_DATA(); // GPIO17
dummy = SpiaRegs.SPIRXBUF;
SpiaRegs.SPITXBUF = Data << 8 ;
while (SpiaRegs.SPISTS.bit.INT_FLAG != 1){}
SpiaRegs.SPISTS.all = 0xFF;
dummy = SpiaRegs.SPITXBUF;

return dummy;
}

请大伙帮忙,看看问题到底出在哪里。谢谢大家

TX dong:

回复 Young Hu:

嗯,已经在这里介绍了:

http://bbs.eeworld.com.cn/thread-485432-1-1.html

赞(0)
未经允许不得转载:TI中文支持网 » 打开ADC中断,会影响SPI吗?
分享到: 更多 (0)