-
Problem with mfc?
Hy,
i hope someone could help me ;)
i have written an programm to controll an fpga card with an existing libary. The example programm was in c and i have to use c++ and the mfc for my project. I managed it to get rid of all error messages and the programm starts without any warnings but if i want to acess the dfpga board i get an Messagebox with the Error
unhandled exception in kartentestprog.exe: 0xC0000005: Access Violation.
Code:
void CKartentestprogDlg::OnStart()
{
// TODO: Add your control notification handler code here
Sleep(1000);
fpga[0] = 1; // <-- here comes the error
fpga[1] = 0;
}
this is the inilization of the board wich works perfekt and all returns are ok.
Code:
int CKartentestprogDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
//connect the fpga and load the .hap file
microenable *board;
fpga_design *design;
volatile unsigned long *fpga;
int rCode;
int PlxClk = 40;
int FpgaClk = 100;
char DesignName[128] = "kartentester.hap";
// -------------------------------------------------------------------
// initialization of hardware
// -------------------------------------------------------------------
board = initialize_microenable();
if (board==NULL) {
//intf ("hardware initialization failed (code %d) : %s\n",
// Me_GetErrCode(NULL),Me_GetErrMsg(NULL));
MessageBox( "Hardwareinizialisation failed", "Error", MB_OK );
return -1;
}
//printf ("hardware initialization ok\n");
MessageBox( "Hardware inizialisation is ok", "No Error", MB_OK );
// -------------------------------------------------------------------
// load a design
// -------------------------------------------------------------------
design = load_design(board,DesignName); // available in standard path
if (design == NULL) {
//printf ("load design %s failed (code %d) : %s\n",
// DesignName,Me_GetErrCode(board),Me_GetErrMsg(board));
MessageBox( "Load of the Design failed", "Error", MB_OK );
return -1;
}
//printf ("load design ok\n");
MessageBox( "Load of the Design is ok", "No Error", MB_OK );
// -------------------------------------------------------------------
// set clocks
// -------------------------------------------------------------------
rCode = set_plx_clk (board,design, PlxClk);
if (rCode) {
//intf ("setting plx clock to %d Mhz failed: error code %d)\n",PlxClk,rCode);
MessageBox( "Clock Settings failed", "Error", MB_OK );
return -1;
}
rCode = set_fpga_clk (board,design, FpgaClk);
if (rCode) {
//printf ("setting fpga clock to %d Mhz failed: error code %d)\n",FpgaClk,rCode);
MessageBox( "Clock Settings failed", "Error", MB_OK );
return -1;
}
//printf ("clock setting ok (plx: %d Mhz, Fpga: %d Mhz)\n",PlxClk,FpgaClk);
MessageBox( "Clock Settings are ok", "No Error", MB_OK );
// -------------------------------------------------------------------
// configure FPGA
// -------------------------------------------------------------------
rCode = configure_fpga(board,design);
if (rCode) {
//printf ("configuration design %s failed: error code %d)\n",DesignName,rCode);
MessageBox( "configuration design failed", "Error", MB_OK );
return -1;
}
//printf ("configuration design %s ok\n",DesignName);
MessageBox( "configuration design is ok", "No Error", MB_OK );
// -------------------------------------------------------------------
// get the access pointer
// -------------------------------------------------------------------
fpga = (volatile unsigned long *) GetAccessPointer (board);
if (fpga == NULL) {
//printf ("memory map failed: error code %d (%s))\n",Me_GetErrCode(board),Me_GetErrMsg(board));
MessageBox( "memory map failed", "Error", MB_OK );
return -1;
}
MessageBox( "Memory Map ok", "No Error", MB_OK );
return 0;
}
SO i hope someone could tell my what this error is all about and where it might come from.
Thanx for all answers
Greets Joerg
-
i thought it must have to do something with the declaration too, but i had tken the code most out of the example i hab for c.
in nearly an beginner with c++
Edit:
Thank you ;) i marked the redefinition of the variable as an comment and now it works real fine ;)