From: richardbarry Date: Thu, 30 Dec 2010 14:01:21 +0000 (+0000) Subject: Continue to develop the MSP430X IAR demo project - still a work in progress. X-Git-Tag: V6.1.1~62 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5475c78a89249cf5419b45ec0550ad96c6b2ecc0;p=freertos Continue to develop the MSP430X IAR demo project - still a work in progress. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1195 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h b/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h index c618ab77d..ebafb803f 100644 --- a/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h +++ b/Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h @@ -68,11 +68,11 @@ #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 0 +#define configUSE_TICK_HOOK 1 #define configCPU_CLOCK_HZ ( 16000000UL ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 5 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 0 diff --git a/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp index f5164b233..783d014d7 100644 --- a/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp +++ b/Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp @@ -1785,6 +1785,9 @@ $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.c + + Debug + $PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.h @@ -1827,6 +1830,9 @@ $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.h @@ -1845,12 +1851,18 @@ $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.h $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.h @@ -1860,6 +1872,9 @@ $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.h @@ -1869,18 +1884,27 @@ $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.h $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.h $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.c + + Debug + $PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.h @@ -1896,30 +1920,45 @@ $PROJ_DIR$\UserExperienceDemo\adcTemp.c + + Debug + $PROJ_DIR$\UserExperienceDemo\adcTemp.h $PROJ_DIR$\UserExperienceDemo\audio.c + + Debug + $PROJ_DIR$\UserExperienceDemo\audio.h $PROJ_DIR$\UserExperienceDemo\balanceBall.c + + Debug + $PROJ_DIR$\UserExperienceDemo\balanceBall.h $PROJ_DIR$\UserExperienceDemo\clock.c + + Debug + $PROJ_DIR$\UserExperienceDemo\clock.h $PROJ_DIR$\UserExperienceDemo\FFT.c + + Debug + $PROJ_DIR$\UserExperienceDemo\FFT.h @@ -1929,51 +1968,78 @@ $PROJ_DIR$\UserExperienceDemo\FFT_430.s43 + + Debug + $PROJ_DIR$\UserExperienceDemo\flashUtils.c + + Debug + $PROJ_DIR$\UserExperienceDemo\flashUtils.h $PROJ_DIR$\UserExperienceDemo\LPM.c + + Debug + $PROJ_DIR$\UserExperienceDemo\LPM.h $PROJ_DIR$\UserExperienceDemo\menuSetting.c + + Debug + $PROJ_DIR$\UserExperienceDemo\menuSetting.h $PROJ_DIR$\UserExperienceDemo\PMM.c + + Debug + $PROJ_DIR$\UserExperienceDemo\PMM.h $PROJ_DIR$\UserExperienceDemo\PowerTest.c + + Debug + $PROJ_DIR$\UserExperienceDemo\PowerTest.h $PROJ_DIR$\UserExperienceDemo\usbTest.c + + Debug + $PROJ_DIR$\UserExperienceDemo\usbTest.h $PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.c + + Debug + $PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.h $PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.c + + Debug + $PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.h diff --git a/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl b/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl index 4050f1d04..5c747173d 100644 --- a/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl +++ b/Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl @@ -193,14 +193,22 @@ // Code // --P(CODE)CODE=5C00-FF7F,10000-45BFF +// *** Modified to place code in high memory and insodoing, testing the port. +// Original code +//-P(CODE)CODE=5C00-FF7F,10000-45BFF +// Modified code +-P(CODE)CODE=10000-45BFF -Z(CODE)CODE_ID // --------------------------- // Constant data // --Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF +// *** Modified to place code in high memory and insodoing, testing the port. +// Original code +//-Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF +// Modified code +-Z(CONST)DATA20_C,DATA20_ID=10000-45BFF // ------------------------------------- diff --git a/Demo/MSP430X_MSP430F5438_IAR/main.c b/Demo/MSP430X_MSP430F5438_IAR/main.c index 2b0821a35..4bcfe27ed 100644 --- a/Demo/MSP430X_MSP430F5438_IAR/main.c +++ b/Demo/MSP430X_MSP430F5438_IAR/main.c @@ -59,16 +59,6 @@ #include "msp430.h" #include "hal_MSP-EXP430F5438.h" -/* The rate at which mainCHECK_LED will toggle when all the tasks are running -without error. Controlled by the check task as described at the top of this -file. */ -#define mainNO_ERROR_CYCLE_TIME ( 5000 / portTICK_RATE_MS ) - -/* The rate at which mainCHECK_LED will toggle when an error has been reported -by at least one task. Controlled by the check task as described at the top of -this file. */ -#define mainERROR_CYCLE_TIME ( 200 / portTICK_RATE_MS ) - /* Codes sent within messages to the LCD task so the LCD task can interpret exactly what the message it just received was. These are sent in the cMessageID member of the message structure (defined below). */ @@ -82,6 +72,7 @@ of the same message and indicate what the status actually is. */ #define mainERROR_DYNAMIC_TASKS ( pdPASS + 1 ) #define mainERROR_COM_TEST ( pdPASS + 2 ) #define mainERROR_GEN_QUEUE_TEST ( pdPASS + 3 ) +#define mainERROR_REG_TEST ( pdPASS + 4 ) /* The length of the queue (the number of items the queue can hold) that is used to send messages from tasks and interrupts the the LCD task. */ @@ -93,7 +84,6 @@ to send messages from tasks and interrupts the the LCD task. */ extern void vRegTest1Task( void *pvParameters ); extern void vRegTest2Task( void *pvParameters ); -static void prvCheckTask( void *pvParameters ); static void prvSetupHardware( void ); static void prvTerminalIOTask( void *pvParameters ); static void prvButtonPollTask( void *pvParameters ); @@ -132,12 +122,11 @@ void main( void ) /* Create the terminal IO and button poll tasks, as described at the top of this file. */ - xTaskCreate( prvTerminalIOTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL ); + xTaskCreate( prvTerminalIOTask, ( signed char * ) "IO", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL ); xTaskCreate( prvButtonPollTask, ( signed char * ) "ButPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); xTaskCreate( vRegTest1Task, "RegTest1", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); xTaskCreate( vRegTest2Task, "RegTest2", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); - xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); vTaskStartScheduler(); } for( ;; ); @@ -209,7 +198,8 @@ static char cBuffer[ 512 ]; /* Output the message that was placed into the cBuffer array within the switch statement above. */ - printf( "%s", cBuffer ); + printf( "%s : %u\n", cBuffer, ( unsigned int ) xTaskGetTickCount() ); + fflush( stdout ); } } /*-----------------------------------------------------------*/ @@ -228,6 +218,8 @@ static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue ) break; case mainERROR_GEN_QUEUE_TEST : sprintf( pcBuffer, "Error: Gen Q test" ); break; + case mainERROR_REG_TEST : sprintf( pcBuffer, "Error: Reg test" ); + break; default : sprintf( pcBuffer, "Unknown status" ); break; } @@ -245,6 +237,12 @@ xQueueMessage xMessage; { /* Check the button state. */ ucState = ( halButtonsPressed() & BUTTON_UP ); + + if( ucState != 0 ) + { + ucState = pdTRUE; + } + if( ucState != ucLastState ) { /* The state has changed, send a message to the LCD task. */ @@ -267,42 +265,7 @@ static void prvSetupHardware( void ) halButtonsInit( BUTTON_ALL ); halButtonsInterruptEnable( BUTTON_SELECT ); LFXT_Start (XT1DRIVE_0); - Init_FLL_Settle( 25000, 488 ); -} -/*-----------------------------------------------------------*/ - -static void prvCheckTask( void *pvParameters ) -{ -volatile unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0; -portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME; -const char *pcStatusMessage = "OK"; - - /* Initialise xNextWakeTime - this only needs to be done once. */ - xNextWakeTime = xTaskGetTickCount(); - - for( ;; ) - { - /* Place this task in the blocked state until it is time to run again. */ - vTaskDelayUntil( &xNextWakeTime, xCycleFrequency ); - - /* Check the reg test tasks are still cycling. They will stop incrementing - their loop counters if they encounter an error. */ - if( usRegTest1Counter == usLastRegTest1Counter ) - { - pcStatusMessage = "Error: RegTest1"; - } - - if( usRegTest2Counter == usLastRegTest2Counter ) - { - pcStatusMessage = "Error: RegTest2"; - } - - usLastRegTest1Counter = usRegTest1Counter; - usLastRegTest2Counter = usRegTest2Counter; - - printf( "%s, tick count = %u\n", pcStatusMessage, ( unsigned int ) xTaskGetTickCount() ); - fflush( stdout ); - } + Init_FLL_Settle( 18000, 488 ); } /*-----------------------------------------------------------*/ @@ -352,6 +315,81 @@ void vApplicationIdleHook( void ) { __bis_SR_register( LPM3_bits + GIE ); } +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ +static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0; +static unsigned long ulCounter = 0; +static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS; +portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; + +/* Define the status message that is sent to the LCD task. By default the +status is PASS. */ +static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS }; + + /* This is called from within the tick interrupt and performs the 'check' + functionality as described in the comments at the top of this file. + + Is it time to perform the 'check' functionality again? */ + ulCounter++; + if( ulCounter >= ulCheckFrequency ) + { + #ifdef LEFT_OVER_FROM_CUT_AND_PASTE + /* See if the standard demo tasks are executing as expected, changing + the message that is sent to the LCD task from PASS to an error code if + any tasks set reports an error. */ + if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) + { + xStatusMessage.lMessageValue = mainERROR_DYNAMIC_TASKS; + } + + if( xAreComTestTasksStillRunning() != pdPASS ) + { + xStatusMessage.lMessageValue = mainERROR_COM_TEST; + } + + if( xAreGenericQueueTasksStillRunning() != pdPASS ) + { + xStatusMessage.lMessageValue = mainERROR_GEN_QUEUE_TEST; + } + #else + /* Check the reg test tasks are still cycling. They will stop incrementing + their loop counters if they encounter an error. */ + if( usRegTest1Counter == usLastRegTest1Counter ) + { + xStatusMessage.cMessageValue = mainERROR_REG_TEST; + } + + if( usRegTest2Counter == usLastRegTest2Counter ) + { + xStatusMessage.cMessageValue = mainERROR_REG_TEST; + } + + usLastRegTest1Counter = usRegTest1Counter; + usLastRegTest2Counter = usRegTest2Counter; + #endif + + /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not + needed (a context switch is going to be performed anyway), but it must + still be provided. */ + xQueueSendFromISR( xLCDQueue, &xStatusMessage, &xHigherPriorityTaskWoken ); + ulCounter = 0; + } + if( ( ulCounter & 0xff ) == 0 ) + { + if( ( LED_PORT_OUT & LED_1 ) == 0 ) + { + LED_PORT_OUT |= LED_1; + LED_PORT_OUT &= ~LED_2; + } + else + { + LED_PORT_OUT &= ~LED_1; + LED_PORT_OUT |= LED_2; + } + } +}