完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好!我用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 settings 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 |
|
相关推荐
1个回答
|
|
您需要两个上拉10K,一个在MCP3201 CS上,另一个在MCP4921 CS上。您不能同时让两个芯片选择活动。选择一个设备,写/读,取消选择,选择另一个设备,写/读,取消选择。你要么将SPI时钟设置为最低频率的设备,要么变得复杂,在设备之间改变时钟。
以上来自于百度翻译 以下为原文 You need two pullups 10K, one on MCP3201 CS and the other on MCP4921 CS. you cannot have both chip selects active at the same time. Select one device, write/read, deselect, the select the other device, write/read, deselect. you either set the SPI clock to the lowest frequency device, or get complicated and change the clock between devices. |
|
|
|
只有小组成员才能发言,加入小组>>
5253 浏览 9 评论
2038 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3219 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2267 浏览 5 评论
792浏览 1评论
688浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
617浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
686浏览 0评论
586浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 11:58 , Processed in 1.460574 second(s), Total 78, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号