Author Topic: UART and simulator  (Read 13983 times)

Offline rad

  • Newbie
  • *
  • Posts: 18
    • View Profile
UART and simulator
« on: August 05, 2010, 01:01:01 PM »
Hi Mark

I try uTasker v.1.4 and add there my first task according to Your tutorial. I use fnDebugMsg() and fnDebugDec() to send some data out. I din´t modify setting code just check that DEMO_UART     0  and SERIAL_PORT_0     2 are defined. Also  LOG_UART0 is defined, so when I start simulator, I can read data from UART0.txt file (there are all data correct). I connect com2 and com5 (com5 is USB to serial) together via null modem, so when I open two instances of the hyperterminal I can send and receive data from terminal one to terminal two correctly. But when I start simulator (I closed all terminals before, of course ;)), I cannot get any data (I try many settings like 1152kbs, Xon/Xoff, no flow control, etc.). Interesting is, that I can open com2 if simulator is running (it must be impossible, if simulator opened com2 before). Do You have any idea? Or missed I some setting?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UART and simulator
« Reply #1 on: August 05, 2010, 01:17:43 PM »
Hi Rad

The simulator settings seem to be correct.

However, also make sure that UART0 is really being opened by the project. Also, check that serial interface is being used a debug output.

To check these, look in application.c:

#if defined SERIAL_INTERFACE && defined DEMO_UART                        // this serial interface is used for debug output and menu based control
        if (!fnSetNewSerialMode(FOR_I_O)) {                              // open serial port for I/O
            return;                                                      // if the serial port could not be opened we quit
        }
        DebugHandle = SerialPortID;                                      // assign our serial interface as debug port
        fnDebugMsg(WELCOME_MESSAGE_UART);
#endif


Put a break point here and see that the expected port is being opened and that the debug handle is then set to the serial handle.


If this all looks OK, you can check the opening of the real COM port. If you are using UART 0 the code that is responsible for opening it is in WinSimMain.cpp:

                case OPEN_PC_COM0:
                    {
                    unsigned long ulSpeed = fnGetValue(doPtr + 1, sizeof(ulSpeed));
                    UART_MODE_CONFIG Mode = (unsigned short)fnGetValue(doPtr + 1 + sizeof(ulSpeed), sizeof(Mode)); // {26}
                    if (sm_hComm0 != INVALID_HANDLE_VALUE) {
                        CloseHandle(sm_hComm0);                          // if we have an open port we want to reconfigure it - so close it
                    }
                    sm_hComm0 = fnConfigureSerialInterface(SERIAL_PORT_0, ulSpeed, Mode); // try to open com since the embedded system wants to use it
                    }
                    break;


If this is executed, check that it opens the expected COM port and that it also doesn't fail for some reason.

Regards

Mark


Offline rad

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: UART and simulator
« Reply #2 on: August 05, 2010, 01:40:41 PM »
Hi Mark,

Thank You for Your reply- I checked SerialPortID and DebugHandle, and both is assigned 12. It is correct?

Rad

Offline rad

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: UART and simulator
« Reply #3 on: August 05, 2010, 02:11:40 PM »
Also OPEN_PC_COM0 runs ok, Mode is 32 and ulSpeed is 117187. But sm_hComm0 is all the time INVALID_HANDLE_VALUE. When I stepped into fnConfigureSerialInterface() I found out that char cCom is 11. I suppose It should be 2 (com2), so I changed it manually to 2 and now it returns valid handle and voila it wors now ;D So I have to find where it is SERIAL_PORT_0 changed :-[ I looked at definition again and its correct value (2). Do You have any idea?

Rad

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UART and simulator
« Reply #4 on: August 05, 2010, 02:25:22 PM »
Hi Rad

Try performing a rebuild of the project. This type of problem is known when using VistualStudio2008 (and possibly others) when not all C-files are recompiled after changing such settings.

After a rebuild (clean) it will be correct.

Regards

Mark

Offline rad

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: UART and simulator
« Reply #5 on: August 05, 2010, 02:49:10 PM »
Hi Mark,

You are right, when I rebuild project, its ok now. And I use Visual Studio 2008;) But when I rebuild whole project I got warning "unary minus operator applied to unsigned type, result still unsigned" file mass_storage.c line 2637.. if (-ulPosition > ptr_utFile->ulFilePosition). Is it ok?

Rad

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: UART and simulator
« Reply #6 on: August 05, 2010, 03:02:42 PM »
Hi Rad

The warning is from the utFAT module. It is OK and can be ignored (code does what is intended but I didn't work out how to stop the compiler complaining...)

Regards

Mark

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: UART and simulator
« Reply #7 on: August 05, 2010, 03:06:38 PM »
Hi Rad,

I get that warning too, don't worry about it its to do with SD card access and doesn't seem to cause a problem.

The rebuilding problem with VS2008 seems to be liked to it not realising that C++ files need to be rebuilt if header files change.

For testing took at com0com to give you virtual null modem serial ports see this post http://www.utasker.com/forum/index.php?topic=54.msg4258#msg4258

Cheers

Martin

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: UART and simulator
« Reply #8 on: July 21, 2011, 09:07:48 PM »
Mark

I have same problem of Rad, but I checked SerialPortID and DebugHandle, and SerialPorID=0 and  DebugHandle=255.

How can i fix the problem?

Thanks


Emerson

Offline tecnoemerson

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: UART and simulator
« Reply #9 on: July 21, 2011, 09:20:33 PM »
Mark

I found the error, #define DEMO_UART was commented, now #define DEMO_UART 0, in app_hW_lpc23xx.h

ok

Thank you

Emerson
« Last Edit: July 21, 2011, 09:28:58 PM by tecnoemerson »