Click here to Skip to main content
15,913,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr3-Sep-09 1:12
psychegr3-Sep-09 1:12 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 3-Sep-09 9:31
professional Randor 3-Sep-09 9:31 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr8-Sep-09 9:40
psychegr8-Sep-09 9:40 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 8-Sep-09 14:42
professional Randor 8-Sep-09 14:42 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr8-Sep-09 22:00
psychegr8-Sep-09 22:00 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr10-Sep-09 4:55
psychegr10-Sep-09 4:55 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 10-Sep-09 18:52
professional Randor 10-Sep-09 18:52 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr11-Sep-09 5:53
psychegr11-Sep-09 5:53 
David,

thank you again for one more time Big Grin | :-D !!
The problem was exactly the one you mentioned above and you were right for one more time!
Finally i gave up the idea to compile the original source code and right now i started from the beginning but this time everything is different!

I started with a windows form template and built the GUI for my program. Everything compiles ok!!

Then i started programming the event handlers for the buttons! The "Exit" button works ok, the "Open File" button brings up the openfiledialog box, the "Save File" brings up the savefiledialog box but doesn't create a file and doesn't save anything and finaly the "Connect" button which when pressed executes the routine to connect to the chip! So far the things go as i was planning to!! Wink | ;) Big Grin | :-D

Now i have 2 more buttons to program. The first is the "Read Ecu" button which dumps all the code from the chip to a file selected from the "Save File" button. The second one is the "Write Ecu" button which writes the file selected from the "Open File" button to the chip!

The way i am thinking now is different! I include a header file to form1.h file which contains all the functions for the buttons' event handlers! The "Connect" button compiles ok! The problem is with the read and write buttons. When I press the read button my app exits with no crash.Confused | :confused: What is happening???

Below is the function which is executed when read button is pressed!

int DumpRegisters (void)
{
	int Stopped = StopChip ();
	unsigned SR, Counter;
	LONG Temp;

	_cprintf(
	"ACCD   %04X\tACCM %01X.%04X%04X" 
	"ACCE   %04X\tHR     %04X" 
	"IX   %01X %04X\tIR     %04X" 
	"IY   %01X %04X\tXMSK   %04X" 
	"IZ   %01X %04X\tYMSK   %04X" 
	"SP   %01X %04X" 
	"PC   %01X %04X" 
	"K      %04X"  ,
		(WORD) GetReg (REG_D),
		(WORD) GetReg (REG_AM2 & 0xf),
		(WORD) GetReg (REG_AM1),
		(WORD) GetReg (REG_AM0),
		(WORD) GetReg (REG_E),
		(WORD) GetReg (REG_H),
		(WORD) (GetReg (REG_K) & 0xf00) >> 8,
		(WORD) GetReg (REG_IX),
		(WORD) GetReg (REG_I),
		(WORD) (GetReg (REG_K) & 0xf0) >> 4,
		(WORD) GetReg (REG_IY),
		(WORD) GetReg (REG_XMYM) >> 8,
		(WORD) (GetReg (REG_K) & 0xf),
		(WORD) GetReg (REG_IZ),
		(WORD) GetReg (REG_XMYM) & 0xff,
		(WORD) GetReg (REG_SK),
		(WORD) GetReg (REG_SP),
		(WORD) GetReg (REG_PK),
		(WORD) GetReg (REG_PC),
		(WORD) GetReg (REG_K));
	_cprintf ("       SMHENZVC210S-PK-" NEWLINE "CCR    ");
	Temp = GetReg (REG_CCR);
	SR = 0x8000;
	for (Counter = 0; Counter < 16; Counter++)
	{
		_putch ((Temp & SR) ? '1' : '0');
		SR >>= 1;
	}
	_cputs ( NEWLINE );
	if (Stopped) RunChip (0);
	return 0;
}


What i need to do is to convert this code to write the data from the chip to a file. GetReg() reads the data from the registers in the chip. If you need more on this i can attach any code you may need! I just don't understand exactly what this function does so that i can convert it!Confused | :confused: Confused | :confused: Confused | :confused:
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 11-Sep-09 7:15
professional Randor 11-Sep-09 7:15 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr15-Sep-09 13:02
psychegr15-Sep-09 13:02 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 16-Sep-09 3:45
professional Randor 16-Sep-09 3:45 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr17-Sep-09 9:28
psychegr17-Sep-09 9:28 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
Randor 17-Sep-09 17:00
professional Randor 17-Sep-09 17:00 
GeneralRe: Program that uses LPT port to communicate with a circuit that programs a cpu! Pin
psychegr20-Sep-09 4:28
psychegr20-Sep-09 4:28 
QuestionEOF Pin
cdpace2-Sep-09 10:25
cdpace2-Sep-09 10:25 
AnswerRe: EOF Pin
Luc Pattyn2-Sep-09 10:45
sitebuilderLuc Pattyn2-Sep-09 10:45 
GeneralRe: EOF Pin
«_Superman_»2-Sep-09 17:24
professional«_Superman_»2-Sep-09 17:24 
GeneralRe: EOF Pin
David Crow3-Sep-09 2:52
David Crow3-Sep-09 2:52 
GeneralRe: EOF Pin
«_Superman_»3-Sep-09 7:09
professional«_Superman_»3-Sep-09 7:09 
QuestionCapture non-client mouse click on sizable window Pin
Darryl Bryk2-Sep-09 10:22
Darryl Bryk2-Sep-09 10:22 
AnswerRe: Capture non-client mouse click on sizable window Pin
«_Superman_»2-Sep-09 17:29
professional«_Superman_»2-Sep-09 17:29 
GeneralRe: Capture non-client mouse click on sizable window Pin
Darryl Bryk3-Sep-09 9:29
Darryl Bryk3-Sep-09 9:29 
GeneralRe: Capture non-client mouse click on sizable window Pin
«_Superman_»3-Sep-09 17:08
professional«_Superman_»3-Sep-09 17:08 
GeneralRe: Capture non-client mouse click on sizable window Pin
Darryl Bryk4-Sep-09 5:26
Darryl Bryk4-Sep-09 5:26 
QuestionHow to disable control animation, combobox Pin
Moak2-Sep-09 9:58
Moak2-Sep-09 9:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.