xilinx sdk整数溢出

时间:2016-04-22 04:45:26

标签: c microblaze xilinx-edk

我正在Xilinx SDK中为micrlaze编写一个c代码。变量定义为:

int xcoi;
int ycoi;
u16 mat[1280][720];

代码读取存储在DDR2内存中的图像数据并将其保存到变量中。

if ((lBtnChanges & bitBtnD) && (lBtnStateNew & bitBtnD))
    {
        for(xcoi = 0; xcoi<1280; xcoi++)
        {
            for(ycoi = 0; ycoi<720; ycoi++)
            {
                mat[xcoi][ycoi] = Xil_In16(pFrame + ycoi*(lLineStride*2) + xcoi*2);
                xil_printf("\n\r xcoi = %d    ycoi = %d \n\r",xcoi,ycoi);
            }

        }
    }

为了检查代码是否正常工作,我在控制台中打印了x和y。我得到错误的输出部分是:

xcoi = 11 ycoi = 253

xcoi = 11 ycoi = 254

xcoi = 11 ycoi = 255

xcoi = 11 ycoi = 256

xcoi = 11 ycoi = 257

xcoi = 11 ycoi = 258

xcoi = 11 ycoi = 259

xcoi = 11 ycoi = 260

xcoi = -547553269 ycoi = 261

xcoi = -547553269 ycoi = 262

xcoi = -547553269 ycoi = 263

xcoi = -547553269 ycoi = 264

xcoi = -547553269 ycoi = 265

xcoi = -547553269 ycoi = 266

xcoi = -547553269 ycoi = 267

为什么在xcoi = 11 ycoi = 260之后xcoi会发生变化? 相反,它应该是下一行中的xcoi = 11 ycoi = 261。

0 个答案:

没有答案