I am porting the main_blinky.c code from the CORTEX-R4_TI_CCS sample code to the LAUNCHXL2-RM46 launchpad board. I’m using CCS v9.10 and FreeRTOS Kernel V10.2.1.
The sample code uses the ParTest.c functions vParTestInitialise and vParTestToggleLED. I have modified both of these functions to reference gioPORTB instead of the hetPORT, and to toggle the two LED’s attached to PORTB bits 1, and 2. I have also modified the ulLEDBits to be 1 and 2, which are the port B bits connected to USER LED A and B.
It seems like the code should work but doesn’t. Any ideas would be greatly appreciated!
partest.c:
/* Port bits connected to LEDs. */
const unsigned long ulLEDBits[] = { 1, 2 }; //PortB LED bits
/* 1 turns a LED on*/
const unsigned long ulOnStates[] = { 1, 0 };
const unsigned long ulNumLEDs = sizeof( ulLEDBits ) / sizeof( unsigned long );
/*-----------------------------------------------------------*/
void vParTestInitialise( void )
{
unsigned long ul;
/* Initalise the IO ports that drive the LEDs */
gioSetDirection( gioPORTB, 0xFF );
/* Turn all the LEDs off. */
for( ul = 0; ul < ulNumLEDs; ul++ )
{
gioSetBit( gioPORTB, ulLEDBits[ ul ], !ulOnStates[ ul ] );
}
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned long ulLED, signed long xValue )
{
if( ulLED < ulNumLEDs )
{
if( xValue == pdFALSE )
{
xValue = !ulOnStates[ ulLED ];
}
else
{
xValue = ulOnStates[ ulLED ];
}
gioSetBit( gioPORTB, ulLEDBits[ ulLED ], xValue );
}
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned long ulLED )
{
unsigned long ulBitState;
if( ulLED < ulNumLEDs )
{
ulBitState = gioGetBit( gioPORTB, ulLEDBits[ ulLED ] );
gioSetBit( gioPORTB, ulLEDBits[ ulLED ], !ulBitState );
}
}
Unless I’m missing something, I don’t think this is a FreeRTOS question, but rather a hardware question…all the same:
There is nothing in these functions that requires the scheduler to be running, so I suggest you just develop and test these functions from main() - before calling vTaskStartScheduler() - just to make your life easier.
I would then suggest looking through the examples TI provide with the board to find some that use the LEDs - try running that example to see the LEDs working - then just copy that. It might be something to do with how the hardware is initialised, before you actually access the LEDs. Perhaps even before calling gioSetDirection() you may need to set up the type of output.
Thank you for your response. What you said about setting up the port for the type of output was the key; I was not calling gioInit(). The port is now working. Thank you.
I do have a question now that is freeRTOS related: the LEDs are not blinking at the programmed rate of 1000 msec, but at about 320mS. I changed configCPU_CLOCK_HZ to 16000000 in FreeRTOSConfig.h and the mainQUEUE_SEND_FREQUENCY_MS to 1000 in main_blinky.c. What am I missing?
I measured the crystal freq on a scope at 16MHz and set:
configCPU_CLOCK_HZ = 16000000
configTICK_RATE_HZ = 1000
mainQUEUE_SEND_FREQUENCY_MS = ( 1000 / portTICK_PERIOD_MS )
The toggle occurs at a 320mS rate instead of a 1000mS rate.
Are there any other timing settings that would affect this? I don’t see any.