大家好!我用PIC24F04KA200做吉他踏板。我用adc和dac mcp3201和mcp4921。有两个问题我不明白:1。如果另一个SPI模块被寻址,ADC MCP31不工作。现在,我在ADC和DAC中同时处理一个代码,作为一个工作。有没有人知道为什么在接收到CLK脉冲后,ADC没有响应,而MCP131的CS是1?我需要在什么地方加个电阻吗?2。直接到dac的Adc听起来像个比特破碎机,换言之,spi更新频率远远不够快。SPI设置是:读和写代码是:主要我做的是调用例程和将输入移动到输出。所以在MP3201的数据表中,它表示
50ksps@2.7V,并以3.3V运行。表格显示CLK也可以达到8000khz。MCP4921数据表声称支持20Mhz的时钟。那么我有机会让它工作得更快并且让其他spi设备像ram模块一样工作吗?谢谢你的帮助!问候,JP
以上来自于百度翻译
以下为原文
Hello all!
I'm working on a guitar pedal using a PIC24F04KA200.
I use the adc and dac mcp3201 and mcp4921.
There are two issues which I do not understand:
1. The adc mcp3201 does not work if another spi module is addressed. Right now I address both adc and dac in a single piece of code, as a work around. Does anyone know why the adc doesn't respond after receiving clk pulses while CS of mcp3201 is 1? do I need to add a resistor somewhere?
2. Adc directly to dac sounds like a bitcrusher, in other words the spi update frequency is nowhere near fast enough.
SPI set
tings are:
void spi1_init(void)
{
SPI1CON1bits.PPRE = 2;
SPI1CON1bits.SPRE = 1;
SPI1CON1bits.MSTEN = 1;
SPI1CON1bits.CKP = 0;
SPI1CON1bits.SSEN = 0;
SPI1CON1bits.CKE = 1;
SPI1CON1bits.SMP = 0;
SPI1CON1bits.MODE16 = 1;
SPI1CON1bits.DISSDO = 0;
SPI1CON1bits.DISSCK = 0;
SPI1CON2 = 0x0000;
SPI1STAT = 0x8000;
LATAbits.LATA4 = 1;
LATAbits.LATA6 = 1;
LATBbits.LATB15 = 1;
}
Read and write code is:
void Write_Guitar() // read and write, since mcp3201 behaves weird
{
LATBbits.LATB15 = 0; //cs
LATAbits.LATA4 = 0;
First_SPI_int = 0x3000 + Guitar_output; //write guitar data
spi1_write(First_SPI_int); //places data in buffer, wait for SPITBF
Guitar_input = ((spi1_read()<<2)>>3); //read from mcp3201 (+remove preceding dont care bits and make it 12 bit)
delay(80); //additional delay for it to actually work
LATBbits.LATB15 = 1;
LATAbits.LATA4 = 1;
}
In main all I do is call routines and move input to output.
So in the datasheet of MCP3201 it says 50ksps @ 2.7V and it runs at 3.3V.
The PIC datasheet shows CLK can go up to 8000khz aswell.
The MCP4921 datasheet claims 20Mhz clock support.
So is there any chance I can get it to work faster and to have other spi devices working like the ram module?
I appreciate your help!
Regards,
JP
0