Read the RL78 demo for release.

This commit is contained in:
Richard Barry 2011-09-09 12:36:32 +00:00
parent 80341af3f5
commit e38ff18256
4 changed files with 75 additions and 25 deletions

View file

@ -57,9 +57,56 @@
licensing and training services. licensing and training services.
*/ */
/* Standard includes. */ /*
#include <stdlib.h> *
#include <string.h> * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
* THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
* APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
*
*
* main() creates the demo application tasks and timers, then starts the
* scheduler.
*
* This demo is configured to run on the RL78/G13 Promotion Board, which is
* fitted with a R5F100LEA microcontroller. The R5F100LEA contains a little
* under 4K bytes of usable internal RAM. The RAM size restricts the number of
* demo tasks that can be created, and the demo creates 13 tasks, 4 queues and
* two timers. The RL78 range does however include parts with up to 32K bytes
* of RAM (at the time of writing). Using FreeRTOS on such a part will allow an
* application to make a more comprehensive use of FreeRTOS tasks, and other
* FreeRTOS features.
*
* In addition to the standard demo tasks, the following tasks, tests and timers
* are created within this file:
*
* "Reg test" tasks - These fill the registers with known values, then check
* that each register still contains its expected value. Each task uses a
* different set of values. The reg test tasks execute with a very low priority,
* so get preempted very frequently. A register containing an unexpected value
* is indicative of an error in the context switching mechanism.
*
* The "Demo" Timer and Callback Function:
* The demo timer callback function does nothing more than increment a variable.
* The period of the demo timer is set relative to the period of the check timer
* (described below). This allows the check timer to know how many times the
* demo timer callback function should execute between each execution of the
* check timer callback function. The variable incremented in the demo timer
* callback function is used to determine how many times the callback function
* has executed.
*
* The "Check" Timer and Callback Function:
* The check timer period is initially set to three seconds. The check timer
* callback function checks that all the standard demo tasks, the reg test tasks,
* and the demo timer are not only still executing, but are executing without
* reporting any errors. If the check timer discovers that a task or timer has
* stalled, or reported an error, then it changes its own period from the
* initial three seconds, to just 200ms. The check timer callback function also
* toggles the user LED each time it is called. This provides a visual
* indication of the system status: If the LED toggles every three seconds,
* then no issues have been discovered. If the LED toggles every 200ms, then an
* issue has been discovered with at least one task.
*
*/
/* Scheduler include files. */ /* Scheduler include files. */
#include "FreeRTOS.h" #include "FreeRTOS.h"
@ -76,19 +123,20 @@ have been reported by any of the standard demo tasks. ms are converted to the
equivalent in ticks using the portTICK_RATE_MS constant. */ equivalent in ticks using the portTICK_RATE_MS constant. */
#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS ) #define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS )
/* These are used to set the period of the demo timer. The demo timer period
is always relative to the check timer period, so the check timer can determine
if the demo timer has expired the expected number of times between its own
executions. */
#define mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT ( 100UL )
#define mainDEMO_TIMER_PERIOD_MS ( mainCHECK_TIMER_PERIOD_MS / mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT )
/* The period at which the check timer will expire, in ms, if an error has been /* The period at which the check timer will expire, in ms, if an error has been
reported in one of the standard demo tasks. ms are converted to the equivalent reported in one of the standard demo tasks, the check tasks, or the demo timer.
in ticks using the portTICK_RATE_MS constant. */ ms are converted to the equivalent in ticks using the portTICK_RATE_MS
constant. */
#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS ) #define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS )
/* The LED toggled by the check task. */ /* These two definitions are used to set the period of the demo timer. The demo
timer period is always relative to the check timer period, so the check timer
can determine if the demo timer has expired the expected number of times between
its own executions. */
#define mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT ( 100UL )
#define mainDEMO_TIMER_PERIOD_MS ( mainCHECK_TIMER_PERIOD_MS / mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT )
/* The LED toggled by the check timer. */
#define mainLED_0 P7_bit.no7 #define mainLED_0 P7_bit.no7
/* A block time of zero simple means "don't block". */ /* A block time of zero simple means "don't block". */
@ -113,7 +161,7 @@ static void prvDemoTimerCallback( xTimerHandle xTimer );
int __low_level_init(void); int __low_level_init(void);
/* /*
* Functions that define the RegTest tasks as described at the top of this file. * Functions that define the RegTest tasks, as described at the top of this file.
*/ */
extern void vRegTest1( void *pvParameters ); extern void vRegTest1( void *pvParameters );
extern void vRegTest2( void *pvParameters ); extern void vRegTest2( void *pvParameters );
@ -122,7 +170,7 @@ extern void vRegTest2( void *pvParameters );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* If an error is discovered by one of the RegTest tasks then this flag is set /* If an error is discovered by one of the RegTest tasks then this flag is set
to pdFAIL. The 'check' task then inspects this flag to detect errors within to pdFAIL. The 'check' timer then inspects this flag to detect errors within
the RegTest tasks. */ the RegTest tasks. */
static short sRegTestStatus = pdPASS; static short sRegTestStatus = pdPASS;
@ -130,7 +178,7 @@ static short sRegTestStatus = pdPASS;
function. */ function. */
static xTimerHandle xCheckTimer = NULL; static xTimerHandle xCheckTimer = NULL;
/* This time is just for demo purposes. */ /* The demo timer. This uses prvDemoTimerCallback() as its callback function. */
static xTimerHandle xDemoTimer = NULL; static xTimerHandle xDemoTimer = NULL;
/* This variable is incremented each time the demo timer expires. */ /* This variable is incremented each time the demo timer expires. */
@ -213,6 +261,7 @@ static void prvCheckTimerCallback( xTimerHandle xTimer )
static portBASE_TYPE xChangedTimerPeriodAlready = pdFALSE, xErrorStatus = pdPASS; static portBASE_TYPE xChangedTimerPeriodAlready = pdFALSE, xErrorStatus = pdPASS;
static unsigned long ulLastDemoTimerCounter = 0UL; static unsigned long ulLastDemoTimerCounter = 0UL;
/* Inspect the status of the standard demo tasks. */
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
{ {
xErrorStatus = pdFAIL; xErrorStatus = pdFAIL;
@ -228,15 +277,16 @@ static unsigned long ulLastDemoTimerCounter = 0UL;
xErrorStatus = pdFAIL; xErrorStatus = pdFAIL;
} }
/* Inspect the status of the reg test tasks. */
if( sRegTestStatus != pdPASS ) if( sRegTestStatus != pdPASS )
{ {
xErrorStatus = pdFAIL; xErrorStatus = pdFAIL;
} }
/* Ensure that the demo timer has expired at /* Ensure that the demo timer has expired at
mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT times in between mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT times in between
each call of this function. */ each call of this function. */
if( ( ulDemoTimerCounter - ulLastDemoTimerCounter ) < ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT - 1 ) ) if( ( ulDemoTimerCounter - ulLastDemoTimerCounter ) < ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT - 1 ) )
{ {
xErrorStatus = pdFAIL; xErrorStatus = pdFAIL;
} }

View file

@ -65,14 +65,14 @@
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>134</YPos><SelStart>6308</SelStart><SelEnd>6308</SelEnd></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\MemMang\heap_1.c</Filename><XPos>0</XPos><YPos>105</YPos><SelStart>4982</SelStart><SelEnd>4982</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\tasks.c</Filename><XPos>0</XPos><YPos>1089</YPos><SelStart>38372</SelStart><SelEnd>38372</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\timers.c</Filename><XPos>0</XPos><YPos>186</YPos><SelStart>9465</SelStart><SelEnd>9465</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>69</YPos><SelStart>4454</SelStart><SelEnd>4454</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\RegTest.s87</Filename><XPos>0</XPos><YPos>109</YPos><SelStart>5308</SelStart><SelEnd>5308</SelEnd></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor> <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>182</YPos><SelStart>8899</SelStart><SelEnd>8899</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\tasks.c</Filename><XPos>0</XPos><YPos>420</YPos><SelStart>19276</SelStart><SelEnd>19276</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>128</YPos><SelStart>6118</SelStart><SelEnd>6130</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\queue.c</Filename><XPos>0</XPos><YPos>236</YPos><SelStart>12907</SelStart><SelEnd>12907</SelEnd></Tab><ActiveTab>3</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions> <Positions>
<Top><Row0><Sizes><Toolbar-013362c8><key>iaridepm.enu1</key></Toolbar-013362c8></Sizes></Row0><Row1><Sizes><Toolbar-0b06e580><key>debuggergui.enu1</key></Toolbar-0b06e580><Toolbar-0ad5a4f8><key>rl78ocd.enu1</key></Toolbar-0ad5a4f8></Sizes></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6><Row7><Sizes/></Row7><Row8><Sizes/></Row8><Row9><Sizes/></Row9><Row10><Sizes/></Row10><Row11><Sizes/></Row11><Row12><Sizes/></Row12><Row13><Sizes/></Row13><Row14><Sizes/></Row14><Row15><Sizes/></Row15><Row16><Sizes/></Row16><Row17><Sizes/></Row17><Row18><Sizes/></Row18><Row19><Sizes/></Row19><Row20><Sizes/></Row20><Row21><Sizes/></Row21><Row22><Sizes/></Row22><Row23><Sizes/></Row23><Row24><Sizes/></Row24><Row25><Sizes/></Row25><Row26><Sizes/></Row26><Row27><Sizes/></Row27><Row28><Sizes/></Row28><Row29><Sizes/></Row29><Row30><Sizes/></Row30><Row31><Sizes/></Row31><Row32><Sizes/></Row32><Row33><Sizes/></Row33><Row34><Sizes/></Row34><Row35><Sizes/></Row35><Row36><Sizes/></Row36></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>662</Bottom><Right>344</Right><x>-2</x><y>-2</y><xscreen>346</xscreen><yscreen>254</yscreen><sizeHorzCX>205952</sizeHorzCX><sizeHorzCY>258656</sizeHorzCY><sizeVertCX>205952</sizeVertCX><sizeVertCY>676171</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>252</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>254</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>258656</sizeHorzCY><sizeVertCX>205952</sizeVertCX><sizeVertCY>258656</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions> <Top><Row0><Sizes><Toolbar-013362c8><key>iaridepm.enu1</key></Toolbar-013362c8></Sizes></Row0><Row1><Sizes><Toolbar-0addce38><key>debuggergui.enu1</key></Toolbar-0addce38><Toolbar-04af27d0><key>rl78ocd.enu1</key></Toolbar-04af27d0></Sizes></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>662</Bottom><Right>344</Right><x>-2</x><y>-2</y><xscreen>346</xscreen><yscreen>254</yscreen><sizeHorzCX>205952</sizeHorzCX><sizeHorzCY>258656</sizeHorzCY><sizeVertCX>205952</sizeVertCX><sizeVertCY>676171</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>252</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>254</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>258656</sizeHorzCY><sizeVertCX>205952</sizeVertCX><sizeVertCY>258656</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop> </Desktop>
</Project> </Project>

View file

@ -15,7 +15,7 @@ TypeViolation=1
UnspecRange=1 UnspecRange=1
ActionState=1 ActionState=1
[DebugChecksum] [DebugChecksum]
Checksum=-1910636464 Checksum=1319205784
[DisAssemblyWindow] [DisAssemblyWindow]
NumStates=_ 1 NumStates=_ 1
State 1=_ 1 State 1=_ 1

View file

@ -17,7 +17,7 @@
<Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>684</ColumnWidth1><ColumnWidth2>182</ColumnWidth2><ColumnWidth3>45</ColumnWidth3></Build><TerminalIO/><Debug-Log><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1218</ColumnWidth1></Debug-Log><Disassembly><MixedMode>1</MixedMode><CodeCovShow>1</CodeCovShow><InstrProfShow>1</InstrProfShow></Disassembly><Find-in-Files><ColumnWidth0>439</ColumnWidth0><ColumnWidth1>62</ColumnWidth1><ColumnWidth2>753</ColumnWidth2></Find-in-Files></Static> <Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>684</ColumnWidth1><ColumnWidth2>182</ColumnWidth2><ColumnWidth3>45</ColumnWidth3></Build><TerminalIO/><Debug-Log><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1218</ColumnWidth1></Debug-Log><Disassembly><MixedMode>1</MixedMode><CodeCovShow>1</CodeCovShow><InstrProfShow>1</InstrProfShow></Disassembly><Find-in-Files><ColumnWidth0>439</ColumnWidth0><ColumnWidth1>62</ColumnWidth1><ColumnWidth2>753</ColumnWidth2></Find-in-Files></Static>
<Windows> <Windows>
<Wnd0> <Wnd2>
<Tabs> <Tabs>
<Tab> <Tab>
<Identity>TabID-25565-17041</Identity> <Identity>TabID-25565-17041</Identity>
@ -29,20 +29,20 @@
</Tab> </Tab>
</Tabs> </Tabs>
<SelectedTab>0</SelectedTab></Wnd0><Wnd1><Tabs><Tab><Identity>TabID-4654-17433</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-14113-4559</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-7454-1824</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd1></Windows> <SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-4654-17433</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-14113-4559</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-7454-1824</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>
<Editor> <Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>134</YPos><SelStart>6308</SelStart><SelEnd>6308</SelEnd></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor> <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>57</YPos><SelStart>3555</SelStart><SelEnd>3555</SelEnd></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions> <Positions>
<Top><Row0><Sizes><Toolbar-013362c8><key>iaridepm.enu1</key></Toolbar-013362c8></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6><Row7><Sizes/></Row7><Row8><Sizes/></Row8><Row9><Sizes/></Row9><Row10><Sizes/></Row10><Row11><Sizes/></Row11><Row12><Sizes/></Row12><Row13><Sizes/></Row13><Row14><Sizes/></Row14><Row15><Sizes/></Row15><Row16><Sizes/></Row16><Row17><Sizes/></Row17><Row18><Sizes/></Row18><Row19><Sizes/></Row19><Row20><Sizes/></Row20><Row21><Sizes/></Row21><Row22><Sizes/></Row22><Row23><Sizes/></Row23><Row24><Sizes/></Row24><Row25><Sizes/></Row25><Row26><Sizes/></Row26><Row27><Sizes/></Row27><Row28><Sizes/></Row28><Row29><Sizes/></Row29><Row30><Sizes/></Row30><Row31><Sizes/></Row31><Row32><Sizes/></Row32><Row33><Sizes/></Row33><Row34><Sizes/></Row34><Row35><Sizes/></Row35><Row36><Sizes/></Row36><Row37><Sizes/></Row37><Row38><Sizes/></Row38></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>629</Bottom><Right>318</Right><x>-2</x><y>-2</y><xscreen>263</xscreen><yscreen>200</yscreen><sizeHorzCX>156548</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>190476</sizeVertCX><sizeVertCY>642566</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>309</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>311</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>316701</sizeHorzCY><sizeVertCX>205357</sizeVertCX><sizeVertCY>258656</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions> <Top><Row0><Sizes><Toolbar-013362c8><key>iaridepm.enu1</key></Toolbar-013362c8></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6><Row7><Sizes/></Row7><Row8><Sizes/></Row8><Row9><Sizes/></Row9><Row10><Sizes/></Row10></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>629</Bottom><Right>318</Right><x>-2</x><y>-2</y><xscreen>263</xscreen><yscreen>200</yscreen><sizeHorzCX>156548</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>190476</sizeVertCX><sizeVertCY>642566</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>309</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>311</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>316701</sizeHorzCY><sizeVertCX>205357</sizeVertCX><sizeVertCY>258656</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop> </Desktop>
</Workspace> </Workspace>