完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在做一些漂亮的时间关键的东西,我有两个while语句,一个上面,一个在我的代码下面……(PurdBoist.RD0= 0){} PigTrimeStudio [PixByTeTyCaleCuth] = Posie;PixyByTeTyCalp+++;而(PotdButs.RD0= 1){},当RD0很高时,我基本上加载一个数组,但是这个代码只是不完全F。够了……有谁知道我怎么能在汇编程序中做到这两个?谢谢
以上来自于百度翻译 以下为原文 Hi, I'm doing some pretty time critical stuff and I have two while statements, one above and one below my code.. while(PORTDbits.RD0==0){} picture_array[pic_byte_count]=PORTE; pic_byte_count++; while(PORTDbits.RD0==1){} I am basically loading an array when RD0 is high but this code is just not quite fast enough... Does anyone know how I can make those two whiles in assembler? Thanks |
|
相关推荐
14个回答
|
|
我怀疑问题是什么。试试这个数组的指针,你看ASM看什么慢了吗?
以上来自于百度翻译 以下为原文 I doubt the while is the issue. Try a pointer for the array Did you look at the ASM to see what is slow? |
|
|
|
|
|
|
|
每个RD0周期只有365s,PIC32运行在200兆赫。它不够快,它占大多数,但似乎到达一个点,然后错过一个,并且在获得图像时周期性地这样做。我不能再减慢相机上的FIFO时钟。D我已经运行了尽可能低的输入频率到相机。所以我需要尽可能瘦这个代码,MT XC32并不惊人…这里的任何帮助都将非常感谢。
以上来自于百度翻译 以下为原文 I only have 365s for each cycle of RD0 and the PIC32 is running at 200Mhz. It's just not quite fast enough, it gets the majority but seems to get to a point then misses one, and does this periodically throughout obtaining the image. I am unable to slow down the FIFO clock on the camera any further and I'm already running the lowest possible input frequency to the camera. So I need to slim this code down as much as possible and mt XC32 isn't amazing... Any help here would be very much appreciated. |
|
|
|
中断需要330NS,我尝试,但它不是理想的,因为它正在削减相当接近。.
以上来自于百度翻译 以下为原文 Interrupt takes 330ns, am trying that but it's not ideal as it's cutting it pretty close. DMA?. |
|
|
|
正如其他人所说:检查程序集输出。还要确保使用最高的优化。比如:
以上来自于百度翻译 以下为原文 As others have said: Check the assembly output. Also make sure to use the highest optimization. Things like:wait_for_high: if(!PORTD & 1) goto wait_for_high might (or might not) be faster. /Ruben |
|
|
|
重新计算每一个循环上的数组索引都会减慢你的速度。有一个预先计算的指针和增量指针会更好。你没有显示整个循环,但类似的是…
以上来自于百度翻译 以下为原文 Recalculating the array index on every loop has GOT to be slowing you down. It would be far better to have a precalculated pointer, and increment the pointer. You didn't show the whole loop, but something like this... unsigned char * byteptr = picture_array for(.....) //start of main loop { while(PORTDbits.RD0==0) ; *byteptr++ = PORTE; while(PORTDbits.RD0==1) ; } |
|
|
|
您的PIC可能有一个PMP模块,您可以使用,而不是位砰砰。
以上来自于百度翻译 以下为原文 Your PIC may have a PMP module which you may be able to use instead of bit-banging. |
|
|
|
在每个循环中重新计算数组索引会减慢你的速度。最好有一个预先计算的指针,然后增加指针。你没有显示整个循环,但是像这样……谢谢,我试着去做。
以上来自于百度翻译 以下为原文 Recalculating the array index on every loop has GOT to be slowing you down. It would be far better to have a precalculated pointer, and increment the pointer. You didn't show the whole loop, but something like this... unsigned char * byteptr = picture_array for(.....) //start of main loop { while(PORTDbits.RD0==0) ; *byteptr++ = PORTE; while(PORTDbits.RD0==1) ; } Thanks I'll try that |
|
|
|
|
|
|
|
PIC的部分号是什么?如果PIC有并行端口(PMP)和DMA,它可以通过硬件读取数据。
以上来自于百度翻译 以下为原文 What is the Part number of your PIC. If you PIC has a Parallel port (PMP) and DMA it can read the data via Hardware. |
|
|
|
我已经完全按照OP的要求做了,即从端口读取图像传感器的像素数据到数组。最快的方法是忽略PMP模块(太慢了),并使用DMA模块直接从端口读取到数组,使用连接到PIXCLK的外部中断管脚初始化。对于ElliotHC:我有几种实现此操作的方法,这取决于PIXCLK是否用LINE_VALID进行门控。如果您给出以下细节,我可能会帮助您编写一些代码:-分辨率(X_Res和Y_Res)。每个像素的位PIXCLK是自由运行的,还是在LINE_VALIDIS LINE_VALILID上进行门控在框架上有效
以上来自于百度翻译 以下为原文 I have done exactly what the OP wants, i.e. reading pixel data from an image sensor from a port into an array. The fastest way is to ignore the PMP module (it's too slow) and use the DMA module to read directly from the port to the array, using an external Interrupt pin connected to PIXCLK to initiate the cell transfers. To ElliotHC: I have a couple of ways of doing this, depending on if PIXCLK is gated with LINE_VALID. If you give the following details, I can probably help out with some code:- Resolution (X_Res and Y_Res). Bits per pixel Is PIXCLK free-running or gated on LINE_VALID Is LINE_VALID gated on FRAME_VALID |
|
|
|
是PIC32MZ2048EFM064。谢谢。传感器输出一个JPG,而且图像越复杂,我从传感器中得到的图像越少(HREF很高),PIXCLK可以自由运行或选通,因为这些设置为JPG模式。在模式1中,HREF变高,你读D2-D9(PORTE)表示所有的PCLK“高”,持续时间HREF变高。模式2是类似的,但是PCLK是自由运行的,VSYNC在帧开始时切换。你能够设置它们是否被选通……我的问题是……如果我减少PLL以便我能够e阅读FIFO与我的PIC32在200MHZ,然后它几乎就像是下一个图像来填补FIFO之前,我可以读出前一个…如果我减少PLL除法器,那么我得到更多的图像,但然后我得到一个点,PIC不够快。
以上来自于百度翻译 以下为原文 It's a PIC32MZ2048EFM064. Thanks. The sensor outputs a JPG and it seems that the more complex the image the less of it I get out of the sensor (HREF being high) PIXCLK can be free running or gated as these are set in the JPG modes.. in Mode 1 HREF goes high and you read D2-D9 (PORTE) for all the PCLK 'high' for the duration HREF is high. Mode 2 is similare but PCLK is free running and VSYNC toggles for the start of the frame. You are able to set if they are gated or not... My problem is this... If I reduce the PLL so that I am able to read the FIFO with my PIC32 at 200MHZ then it's almost as if the next image is coming in and filling up the FIFO before I can read the previous one out... If I reduce the PLL divider then I get more image but then I get to a point where the PIC isn't fast enough. |
|
|
|
以下代码以链式模式设置DMA信道3-6,以读取多达256k到缓冲区中。完全或帧有效。禁用DMA信道。因为它使用INT2作为PIXCLK,但是您可以通过PPS使用任何INT,只需要更改CHSIRQ的矢量编号。有一些宏(如READPORT())需要更改,但是它们应该是显而易见的。
以上来自于百度翻译 以下为原文 The following code sets up the DMA channels 3-6 in chained mode to read up to 256k into a buffer. The code:- Configures DMA Waits for Frame Valid to be low (in case of middle of previous frame) Waits for Rising edge on Frame Valid Kicks off DMA (which channel depends on size of transfer) Waits for DMA to complete Or Frame Valid to fall. Disables DMA channels. As is it uses INT2 for PIXCLK, but you can use any INT via PPS, just change the vector number for CHSIRQ. There are some macros (like READPORT()) which will need changing, but they should be obvious. #define MT_PORT PORTE int MT_ReadFrame(uint8_t *buf) { BITCLR(MT_OE); //MT9V output enable int len=MT_XRES*MT_YRES+1; int nch=(len)/65535; uint8_t *dst; if (buf) dst=buf; else dst=MTFrameBuf; INTCONbits.INT2EP=0; IFS0bits.INT2IF=0; DCH3CON=0; DCH3ECON=0; DCH3SSA=VirtToPhys((void*)&MT_PORT); DCH3SSIZ=1; DCH3CSIZ=1; DCH3ECONbits.CHSIRQ=13; // INT2 DCH3ECONbits.SIRQEN=1; DCH4CON=0; DCH4ECON=0; DCH4SSA=VirtToPhys((void*)&MT_PORT); DCH4SSIZ=1; DCH4CSIZ=1; DCH4ECONbits.CHSIRQ=13; // INT2 DCH4ECONbits.SIRQEN=1; DCH5CON=0; DCH5ECON=0; DCH5SSA=VirtToPhys((void*)&MT_PORT); DCH5SSIZ=1; DCH5CSIZ=1; DCH5ECONbits.CHSIRQ=13; // INT2 DCH5ECONbits.SIRQEN=1; DCH6CON=0; DCH6ECON=0; DCH6SSA=VirtToPhys((void*)&MT_PORT); DCH6SSIZ=1; DCH6CSIZ=1; DCH6ECONbits.CHSIRQ=13; // INT2 DCH6ECONbits.SIRQEN=1; DCH7CON=0; DCH7ECON=0; DCH7SSA=VirtToPhys((void*)&MT_PORT); DCH7SSIZ=1; DCH7CSIZ=1; DCH7ECONbits.CHSIRQ=13; // INT2 DCH7ECONbits.SIRQEN=1; switch(nch) { case 4: DCH7DSA=VirtToPhys(dst); DCH7DSIZ=65535; len-=65535; dst+=65535; DCH7INT=0x000b0000; DCH7CONbits.CHCHNS=1; DCH7CONbits.CHPRI=3; DCH6CONbits.CHCHN=1; DCH6CONbits.CHCHNS=1; case 3: DCH6DSA=VirtToPhys(dst); DCH6DSIZ=65535; len-=65535; dst+=65535; DCH6INT=0x000b0000; DCH6CONbits.CHCHNS=1; DCH6CONbits.CHPRI=3; DCH5CONbits.CHCHN=1; DCH5CONbits.CHCHNS=1; case 2: DCH5DSA=VirtToPhys(dst); DCH5DSIZ=65535; len-=65535; dst+=65535; DCH5INT=0x000b0000; DCH5CONbits.CHCHNS=1; DCH5CONbits.CHPRI=3; DCH4CONbits.CHCHN=1; DCH4CONbits.CHCHNS=1; case 1: DCH4DSA=VirtToPhys(dst); DCH4DSIZ=65535; len-=65535; dst+=65535; DCH4INT=0x000b0000; DCH4CONbits.CHCHNS=1; DCH4CONbits.CHPRI=3; DCH3CONbits.CHCHN=1; DCH3CONbits.CHCHNS=1; case 0: DCH3DSA=VirtToPhys(dst); DCH3DSIZ=len; DCH3INT=0x000b0000; DCH3CONbits.CHPRI=3; } while((READPORT(MT_FRAMEVALID))) Nop(); PixCtr=0; IEC0bits.INT2IE=0; switch(nch) { case 0: while(!(READPORT(MT_FRAMEVALID))); DCH3CONSET=0x80; DCH3ECONbits.CFORCE=1; break; case 1: while(!(READPORT(MT_FRAMEVALID))); DCH4CONSET=0x80; DCH4ECONbits.CFORCE=1; break; case 2: while(!(READPORT(MT_FRAMEVALID))); DCH5CONSET=0x80; DCH5ECONbits.CFORCE=1; break; case 3: while(!(READPORT(MT_FRAMEVALID))); DCH6CONSET=0x80; DCH6ECONbits.CFORCE=1; break; case 4: while(!(READPORT(MT_FRAMEVALID))); DCH7CONSET=0x80; DCH7ECONbits.CFORCE=1; break; } while((!(DCH3INT&0x0b))&&(READPORT(MT_FRAMEVALID))) Nop(); if (!READPORT(MT_FRAMEVALID)) { DCH3ECONSET=0x40; DCH3CONCLR=0x80; DCH4ECONSET=0x40; DCH4CONCLR=0x80; DCH5ECONSET=0x40; DCH5CONCLR=0x80; DCH6ECONSET=0x40; DCH6CONCLR=0x80; DCH7ECONSET=0x40; DCH7CONCLR=0x80; } IEC0bits.INT4IE=CTPIVal; //Re-enable TP Interrupt IEC0bits.INT2IE=0; FrameDone=1; BITSET(MT_OE); //MT9V output enable return 0; } |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5234 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3200 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
670浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 23:25 , Processed in 1.584620 second(s), Total 103, Slave 87 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191