Author Topic: Visual C++ files  (Read 8756 times)

Offline freewill78

  • Newbie
  • *
  • Posts: 7
    • View Profile
Visual C++ files
« on: January 17, 2009, 04:45:37 PM »
Hello,

I'm just started on evaluating utasker.

The first question I'm having confusion is about:

For example, Under uTaskerV1.3 project folder; Are the those files(i.e application.c) same that are used by Visual Studio for the simulator and for the KEIL/IAR etc compilers?

How is it possible with the same files, Visual Studio controls PC ethernet card, and KEIL/IAR controls MCU Ethernet?
There should be a bridge that Visual Studio bypass actual MCU drivers files, and process its own.







Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
Re: Visual C++ files
« Reply #1 on: January 17, 2009, 05:09:09 PM »
Hi

The idea is that the simulator (VisualStudio) uses exactly the same code as the target (that is, as compiled by the cross compiler - in your case keil, but generally could be any C-compiler). If you change anything in the project's code this change is valid for the simulation project AND the target project - there is no difference.

The only thing that the simulator does differently (apart from a small amount of code - mainly in the drivers -which is conditional: see #define _WINDOWS) is to add an extra layer to monitor changes to peripheral register settings and execute the functions that these would perform.

If, for example, an Ethernet frame has been copied to the Ethernet memory and the controller flags show that it should be sent it will then be passed on to the NIC and transmitted to the Network from the PC.
On the other hand, if the WinPCap thread receives an Ethernet frame matching the simulated device's MAC address (or a broadcast, or any when set to promiscuous mode) it will copy it to Ethernet RX RAM and set the Ethernet Rx interrupt flags, causing the Ethernet interrupt (if enabled) to be called. Therefore the simulator allows the embedded code to be executed (including interrupt routines) - exactly the same code as will be running later on the target.

There is therefore not two projects - one for the simulator and one for the target; this would not be a good idea because it would mean two projects need to be maintained and are not guarantied to be the same code, which would greatly detract from the usefulness and reliability of the simulation!

The conclusion (and purpose of the simulator) is that you can develop, test and debug most real project code in the simulator environment (faster and better debugging possibilities than on a real target) and once the project is executing correctly on the simulator so can simply compile the project with Keil and download the code. The code has already been tested and the probability of it also working correctly on the HW target is almost 100%.

When developing software which interacts with Ethernet/IP (like adding a server or client) there is usually absolutely no reason for wanting to do any development work on the target - this can reduce such development times quite easily by 50..80%. For example: I have worked on a project with Keil (web server extensions) but never needed to use the Keil debugger for any new code. Once it was working correctly with the simulator it worked automatically on the board.

Therefore try some code changes in the simulator. Test that they work as expected (in the simulator), compile again with Keil, download to the target and you should already be finished...!

Good luck

Regards

Mark

Offline freewill78

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Visual C++ files
« Reply #2 on: January 17, 2009, 08:49:26 PM »
Thanks Mark.
Very useful information and I agree this is the best method for least confusion and easiest development.
I wanted to make sure, and I know now, #define _WINDOWS does the trick...