Download FreeRTOS
 

Quality RTOS & Embedded Software

KERNEL
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

Win32 Simulator for FreeRTOS
Using Visual C++


This page relates to an older contributed simulator. Please see the official FreeRTOS Windows simulator that can be build using Visual Studio 2010 Express and Eclipse with MingW (GCC).


The Win32 FreeRTOS simulator was kindly provided by Dushara Jayasinghe. I have used it with Visual Studio 2008 Express Edition (which can be downloaded for free) under WinXP and found it to be a very valuable tool.

The simulator source code is included as a FreeRTOS contributed port. Below are some usage notes from Dushara.


Introduction

The FreeRTOS WIN32 port allows your embedded application to be simulated on a PC with Microsoft windows XP (may work on NT as well).

The source code is available in the FreeRTOS download, but requires unzipping separately from the main FreeRTOS code. Once unzipped you will find the Visual Studio project in the FreeRTOS/Demo/Win32 directory.

To enable compilation, the following Pre-processor definitions must be present:

    WIN32
    _WIN32_WINNT=0x0400
    WINVER=0x400
Each FreeRTOS task that you create is wrapped by a Windows thread. This has a significant implication: The stack size argument in 'xTaskCreate' is ignored (meaning you won't catch stack overflow errors via the simulator).


Interrupts

The simulator provides 30 interrupt sources (1 - 30). These are defined in cpuemu.h The following API calls are useful for interrupt handling:

iPortSetIsrHandler - Set the interrupt handler.
vPortEnableInt - enable the specified interrupt.
vPortDisableInt - disable the specified interrupt.

Interrupt generation is simulated using separate threads.

Create the interrupt generator thread as follows:

SetThreadPriority(CreateThread(NULL, 0, irq_generator, NULL, 0, NULL), THREAD_PRIORITY_ABOVE_NORMAL);

Sample interrupt generator:

DWORD WINAPI irq_generator(LPVOID lpParameter) 
{
    for(;;)
    {
            // wait for some windows event.
            __generate_interrupt(IRQ_NO);
    }
}
tick_generator in port.c can be used as a good example.


Important Notes

  • System ticks occur approx every 15ms.
  • Your vApplicationIdleHook() should include a Sleep(0) call. If the only thing your IDLE thread does is pat the watchdog, you can use Sleep(INFINITE). Note added by RB: I found Sleep(Infinite) upset the debugger when stepping through the code and removed it for debugging.







Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.