完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用24FJ256GB206通过SPI1读取一个单独的16位AD转换器,每8毫秒转换一次。我正在读取HyByter,LoBooad,并将这些写入SD卡——SPI2-I也读取状态字节,但丢弃它。随着每一关,我也通过SPI3(主模式)发送16位值到从模式的一个32 MX764 F128L的SPI3。我使用手动GPIO作为我的SS(或CS)。应该发生的是,32 MX读取传入的“实时”16位数据,并将其绘制在7“TFT显示器上”,它也从SD卡中检索相同的存储数据,并在同一屏幕上绘制垂直分离的数据。D数据正在被成功地绘制,但是我还不能得到实时数据来绘图(我只得到一个水平的直线:请在这里看到显示图像)。首先我从24FJ检查SPI3主控器,当在一个循环中发送0xAAAA时,它工作得很好(请参阅范围输出)。然而,当我发送实时数据(每8ms 16位)时,我得到了一个相当讨厌的输出,输出时钟失真,输出有时保持高电平(或者,如果最后一位高,这是正确的吗?)显然,SPI3没有问题,它发送了0xAAAA,没有麻烦——在上面的代码中必须有一些坏的东西——SPI3CON1被设置为0x043E(16位,活动到空闲,主控,2MHz),并且我确认了我的手动SS(CS)正在工作。请注意,我每次写入总共3×512字节(3)。* 512/2个16位值。SD卡和其他两个SPI工作正常。32 MX端可能有问题,但我想确保24FJ工作正常。首先,您的想法赞赏。
以上来自于百度翻译 以下为原文 I'm using a 24FJ256GB206 to read a separate 16 bit AD converter via SPI1 with one conversion every 8mS. I am reading hibyte, lobyte and writing those to an SD card - with SPI2 - I also read the status byte but discard it. With each pass I am also transmitting the 16 bit value via SPI3 (master mode) to a 32MX764F128L's SPI3 in slave mode. I am using a manual GPIO as my SS (or CS). int plotSECTOR( LBA a) // a LBA of sector requested // returns TRUE if successful { unsigned int r, i, p, q; AD_ON;//enable AD converter (working fine) r = sendSDCmd( WRITE_SINGLE, ( a << 9)); writeSPI( DATA_START); for( i=0; i while(AD_READY);//16 bit AD converter 8mS cycle - this goes low when ready writeSPI(p=readSPI1());//write to SD card 8 hi bits NOTE: SPI2 is for SD card works fine writeSPI(q=readSPI1());//write to SD card 8 lo bits readSPI1();//read 8 status bits (discard) _LATG7=0;//enable slave SS/CS line writeSPI3(p<<8|q);//assemble 16 bits and write to 32MX slave _LATG7=1;//disable slave } // send dummy CRC writeSPI(0xFF); writeSPI(0xFF); // check if data accepted if ( (r = readSPI() & 0xf) == DATA_ACCEPT) { for( i=0xffff; i>0; i--) { // wait for end of write if ( (r = readSPI())) break; } } // accepted else {r = FAIL;B3;while(1);} //} // command accepted // remember to disable the card AD_OFF; disableSD(); return( r); // return TRUE if successful } // plotSECTOR What is supposed to happen is that the 32MX reads the incoming "real time" 16 bit data and plots it on a 7" TFT display - it then also retrieves the same stored data from the SD card and it plots that on the same screen -separated vertically. The retrieved SD data is being successfully plotted but I can't yet get the real time data to plot (I just get a horizontal straight line: please see display image here). First I checked SPI3 master from the 24FJ and, when in a loop to send 0xAAAA, it works fine (please see scope output). However when I am transmitting the real time data (16 bits every 8mS) I get a rather nasty looking output with misshapen clock pulses and an output which sometimes remains high after transmission (or is this correct if last bit high?) There is obviously no problem with SPI3 which sends 0xAAAA with no trouble - there has to be something bad in my above code - SPI3CON1 is set to 0x043E (16 bit, active to idle, master, 2MHz) and I have confirmed my manual SS(CS) is working. Please note I'm writing a total of 3*512 bytes each time (3*512/2 16 bit values). The SD card and the two other SPIs are working fine. The 32MX end may have a problem but I want to be sure the 24FJ is working OK first. Your thoughts appreciated. Attached Image(s) |
|
相关推荐
1个回答
|
|
更新:我似乎已经固定了“丑陋”的时钟脉冲,这是由于32 MX具有CKE=1,而24FJ CKE是0。两个现在都是0。看起来好的数字被发送到32 MX,它有以下简化代码,用J=3(512字节块的数量)接收它们。请注意,这里我已经简化了Y值,它必须被缩放以适合屏幕上的正确位置。SPI3的设置是16位,从,CKE=0,输出禁用,SS禁用,(SPI3CON=0x1400)
以上来自于百度翻译 以下为原文 Update: I seem to have fixed the "ugly" clock pulses which were due to the 32MX having CKE=1 while the 24FJ CKE was 0. Both are now 0. It looks as if good numbers are being sent to the 32MX which has the following simplified code to receive them with j =3 (number of 512 byte blocks) void RealTimePlot(short j)//note if y is put at 200, this works perfectly { short x, y i; for(i=0;i while(_RD14);//this port gates each 16 bit integer y=readSPI3();//read the gated value from master 24FJ's SPI3 x=(i+15);//note that there are 3*B_SIZE 16 bit integers now y max = 255 x max=511(?) PutPixel(x,y);//this function is proven to work } } please note that I have here simplified the y value which has to be scaled to fit in the right place on the screen. The setting for SPI3 is 16 bit, slave, CKE=0, output disabled, SS disabled, (SPI3CON=0x1400) |
|
|
|
只有小组成员才能发言,加入小组>>
5132 浏览 9 评论
1985 浏览 8 评论
1914 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3153 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2213 浏览 5 评论
702浏览 1评论
593浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
476浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
608浏览 0评论
499浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-5 12:19 , Processed in 1.313192 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号