Week 10 Progress:

     Ilya said that he is having some problems with the board and is still working on getting the VHDL compatible with Xilinx so that it can download into the FPGA chip.  Since we cannot possibly finish the full version of the the logic analyzer in the time allotted, we decide to try to just get the version number of the FPGA.  As described on our protocol description. I will send S01 in hex and then receive one byte.  I don't know if we can even complete this because we're having all this trouble with the board and VHDL.  Since I'm in charge of the software, I created the the get version option in my tool bar and direct it to the FPGA version form.  I tested the send and receive of the get version and everything seems to work.  Hopefully Ilya and Jae can get something for the hardware so we can hook up the Palm and have something to demonstrated besides all the simulations.  I also found some bugs in the sending of the trigger condition.  I added the function to get the object pointer and redid all my test cases.

 

Fig 1. this is to get the version number.

Here is the Code that accompanies this, note that it also receives but I cannot demonstrate this because I cannot screen capture the actual palm.

static void EditDoMenuCommand(Word command)
{
//FieldPtr fld;
FormPtr frm;
FieldPtr fld;
CharPtr newText;
char sendbits[16];
unsigned short num, *ref;
Err error;
Word fldIndex;
Handle newHandle;
Boolean handled = false;
Long toReceive, numReceived; 
Long timeout; 
Err err; 
char buff[1];//[myReceiveBuffSize]; 
//frm = FrmGetActiveForm();
// Do the appropriate action for the menu command selected.
switch (command)
{
case OptionsAboutUs:
// Load the info form, then display it.
frm = FrmInitForm(AboutUsForm);
FrmDoDialog(frm);

// Delete the info form.
FrmDeleteForm(frm);
break;
case OptionsInstructions:
// Load the info form, then display it.
frm = FrmInitForm(InfoForm);
FrmDoDialog(frm);

// Delete the info form.
FrmDeleteForm(frm);
break;
case OptionsGetFPGAVersion:
// Load the info form, then display it.
frm = FrmInitForm(VersionForm);
rec0 = "VersionTest";


sendbits[0]='s';
sendbits[1]=0x01;
sendbits[2]='\0';
ref = #
SysLibFind("Serial Library",ref);
SerOpen(num,0,57600);
SerSend(num,sendbits,StrLen(sendbits),&error);
SerSendWait(num,-1);

toReceive = 1; // want to receive 10 bytes 
timeout = SysTicksPerSecond () *10; /// 2; // 1/2 sec inter-byte timeout 

ErrFatalDisplayIf (toReceive > sizeof(buff), "buffer overflow"); 

numReceived = SerReceive (num, buff, toReceive, timeout, &err); 
if ( err == serErrLineErr ) { 
// Take some action and clear the error (see SerGetStatus) 
// Need to clear the error status or all subsequent receive calls will fail 
SerClearErr (num); 

SerClose(num);
rec0=buff;

newHandle = MemHandleNew(StrLen(rec0) + 1);
newText = MemHandleLock(newHandle);
StrCopy(newText, rec0);
fldIndex = FrmGetObjectIndex(frm, VersionVersionField);
fld = FrmGetObjectPtr(frm, fldIndex);
FldSetTextHandle(fld, newHandle);
FrmDoDialog(frm);

// Delete the info form.
FrmDeleteForm(frm);
break;
}
}

Fig 2.  This is the new and correct trigger condition format.  Check with the protocol description and also the ASCII character charts of the previous weeks to parse this.  

Here is the code for this.

static Boolean MainFormHandleEvent(EventPtr event)
{
FormPtr frm;
//Word fldIndex;
//FieldPtr fld;
Boolean handled = false;
EventType newEvent;
char sendbits[16], *pointer;
char msg[] = "logon\n";
//CharPtr text;
unsigned short num, *ref;
Err error, *perr;
pointer = &sendbits[0];
perr = &error;
ref = #


frm = FrmGetActiveForm();


switch (event->eType)
{
case ctlSelectEvent:
if (event->data.ctlEnter.controlID == LogicMainExitButton)
{
MemSet(&newEvent, sizeof(EventType), 0);
newEvent.eType = appStopEvent;
EvtAddEventToQueue(&newEvent);
handled = true;
}
else if (event->data.ctlEnter.controlID == LogicMainBsendButton)
{
sendbits[0]='w';
sendbits[1]=0x01;
sendbits[3]=0x03;
sendbits[4]='\0';
SysLibFind("Serial Library",ref);
//*Channel 0 and 1
if (CtlGetValue(GetObjectPtr(LogicMainCh0dcCheckbox))!=0)
if (CtlGetValue(GetObjectPtr(LogicMainCh1dcCheckbox))!=0)
//*Both don't care
sendbits[2] = 0x77;

else
//*Don't care and high
if (CtlGetValue(GetObjectPtr(LogicMainCh1hlCheckbox))!=0)
sendbits[2] = 0x17;
//*Don't care and low
else
sendbits[2] = 0x27; 
else
//*High 
if (CtlGetValue(GetObjectPtr(LogicMainCh0hlCheckbox))!=0)
//*High and don't care
if (LogicMainCh1dcCheckbox)
sendbits[2] = 0x71;
else
//*High and High
if (LogicMainCh1hlCheckbox)
sendbits[2] = 0x11;
//*High and low
else
sendbits[2] = 0x21; 

else
//*low and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh1dcCheckbox))!=0)
sendbits[2] = 0x72;
else
//*low and High
if (CtlGetValue(GetObjectPtr(LogicMainCh1hlCheckbox))!=0)
sendbits[2] = 0x12;
//*low and low
else
sendbits[2] = 0x22; 
SerOpen(num,0,57600);
SerSend(num,sendbits,StrLen(sendbits),&error);
SerSendWait(num,-1);
SerClose(num);
//*Channel 2 and 3
if (CtlGetValue(GetObjectPtr(LogicMainCh2dcCheckbox))!=0)
if (CtlGetValue(GetObjectPtr(LogicMainCh3dcCheckbox))!=0)
//*Both don't care
sendbits[2] = 0x77;
else
//*Don't care and high
if (CtlGetValue(GetObjectPtr(LogicMainCh3hlCheckbox))!=0)
sendbits[2] = 0x17;
//*Don't care and low
else
sendbits[2] = 0x27; 
else
//*High 
if (CtlGetValue(GetObjectPtr(LogicMainCh2hlCheckbox))!=0)
//*High and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh3dcCheckbox))!=0)
sendbits[2] = 0x71;
else
//*High and High
if (CtlGetValue(GetObjectPtr(LogicMainCh3hlCheckbox))!=0)
sendbits[2] = 0x11;
//*High and low
else
sendbits[2] = 0x21; 

else
//*low and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh3dcCheckbox))!=0)
sendbits[2] = 0x72;
else
//*low and High
if (CtlGetValue(GetObjectPtr(LogicMainCh3hlCheckbox))!=0)
sendbits[2] = 0x12;
//*low and low
else
sendbits[2] = 0x22; 
SerOpen(num,0,57600);
SerSend(num,sendbits,StrLen(sendbits),&error);
SerSendWait(num,-1);
SerClose(num);
//*Channel 4 and 5
if (CtlGetValue(GetObjectPtr(LogicMainCh4dcCheckbox))!=0)
if (CtlGetValue(GetObjectPtr(LogicMainCh5dcCheckbox))!=0)
//*Both don't care
sendbits[2] = 0x77;
else
//*Don't care and high
if (CtlGetValue(GetObjectPtr(LogicMainCh5hlCheckbox))!=0)
sendbits[2] = 0x17;
//*Don't care and low
else
sendbits[2] = 0x27; 
else
//*High 
if (CtlGetValue(GetObjectPtr(LogicMainCh4hlCheckbox))!=0)
//*High and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh5dcCheckbox))!=0)
sendbits[2] = 0x71;
else
//*High and High
if (CtlGetValue(GetObjectPtr(LogicMainCh5hlCheckbox))!=0)
sendbits[2] = 0x11;
//*High and low
else
sendbits[2] = 0x21; 

else
//*low and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh5dcCheckbox))!=0)
sendbits[2] = 0x72;
else
//*low and High
if (CtlGetValue(GetObjectPtr(LogicMainCh5hlCheckbox))!=0)
sendbits[2] = 0x12;
//*low and low
else
sendbits[2] = 0x22; 
SerOpen(num,0,57600);
SerSend(num,sendbits,StrLen(sendbits),&error);
SerSendWait(num,-1);
SerClose(num);
//*Channel 6 and 7
if (CtlGetValue(GetObjectPtr(LogicMainCh6dcCheckbox))!=0)
if (CtlGetValue(GetObjectPtr(LogicMainCh7dcCheckbox))!=0)
//*Both don't care
sendbits[2] = 0x77;
else
//*Don't care and high
if (CtlGetValue(GetObjectPtr(LogicMainCh7hlCheckbox))!=0)
sendbits[2] = 0x17;
//*Don't care and low
else
sendbits[2] = 0x27; 
else
//*High 
if (CtlGetValue(GetObjectPtr(LogicMainCh6hlCheckbox))!=0)
//*High and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh7dcCheckbox))!=0)
sendbits[2] = 0x71;
else
//*High and High
if (CtlGetValue(GetObjectPtr(LogicMainCh7hlCheckbox))!=0)
sendbits[2] = 0x11;
//*High and low
else
sendbits[2] = 0x21; 

else
//*low and don't care
if (CtlGetValue(GetObjectPtr(LogicMainCh7dcCheckbox))!=0)
sendbits[2] = 0x72;
else
//*low and High
if (CtlGetValue(GetObjectPtr(LogicMainCh7hlCheckbox))!=0)
sendbits[2] = 0x12;
//*low and low
else
sendbits[2] = 0x22; 
SerOpen(num,0,57600);
SerSend(num,sendbits,StrLen(sendbits),&error);
SerSendWait(num,-1);
SerClose(num);

I had to add the Get ObjectPtr function to my program and also use the CtlGetValue to get the actual value of the check box.

Fig 3.  The Get FPGA Version option in the menu.

 

Fig 4.  The Version form.  Note that nothing is sent to the emulator, that's why it displays junk.  If it was downloaded to the palm and something is sent from hyperterminal, we would get whatever that was sent.