-Yes, the .hex generated by example program of Keil works well when I burn in Teensy 3.2 via command line(Keil can generate .hex also).
After burning I checked with LED and pin no 54 and 55 are glowing.
-Version 1.6.5.
-Processor-MK20DX256VLH7.
-I used default blinky example(glows pin 13 of teensy 3.2 and pin 50 of the controller).
-.axf/.hex file of Keil example program glows PTC9 and PTC10 fast and very fast.(I used 16Mhz crystal for my processor and in program the core clock setting is 20.971520Mhz).
Let me know what else to share.
Below is the Blinky.c program of Keil.
#include "MK20D7.h" // Device header
#include "cmsis_os.h"
osThreadId tid_phaseA; /* Thread id of thread: phase_a */
osThreadId tid_phaseB; /* Thread id of thread: phase_b */
osThreadId tid_phaseC; /* Thread id of thread: phase_c */
osThreadId tid_clock; /* Thread id of thread: clock */
#define LED_A 1
#define LED_B 1
#define LED_C 1
#define LED_CLK 0
const uint32_t led_mask[] = {1UL << 9, 1UL << 10};
/*------------------------------------------------------------------------------
configure LED pins
*------------------------------------------------------------------------------*/
__INLINE static void LED_Initialize(void) {
SIM->SCGC5 |= (1UL << 11); /* Enable Clock to Port C */
PORTC->PCR[9] = (1UL << 8); /* Pin is GPIO */
PORTC->PCR[10] = (1UL << 8); /* Pin is GPIO */
PTC->PDOR = (led_mask[0] |
led_mask[1] ); /* switch LEDs off */
PTC->PDDR = (led_mask[0] |
led_mask[1] ); /* enable Output */
}
/*------------------------------------------------------------------------------
Switch on LEDs
*------------------------------------------------------------------------------*/
__INLINE static void LED_On (uint32_t led) {
PTC->PCOR = led_mask[led];
}
/*------------------------------------------------------------------------------
Switch off LEDs
*------------------------------------------------------------------------------*/
__INLINE static void LED_Off (uint32_t led) {
PTC->PSOR = led_mask[led];
}
/*----------------------------------------------------------------------------
* Function 'signal_func' called from multiple threads
*---------------------------------------------------------------------------*/
void signal_func (osThreadId tid) {
osSignalSet(tid_clock, 0x0100); /* set signal to clock thread */
osDelay(500); /* delay 500ms */
osSignalSet(tid_clock, 0x0100); /* set signal to clock thread */
osDelay(500); /* delay 500ms */
osSignalSet(tid, 0x0001); /* set signal to thread 'thread' */
osDelay(500); /* delay 500ms */
}
/*----------------------------------------------------------------------------
* Thread 1 'phaseA': Phase A output
*---------------------------------------------------------------------------*/
void phaseA (void const *argument) {
for (;
{
osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */
LED_On (LED_A);
signal_func(tid_phaseB); /* call common signal function */
LED_Off(LED_A);
}
}
/*----------------------------------------------------------------------------
* Thread 2 'phaseB': Phase B output
*---------------------------------------------------------------------------*/
void phaseB (void const *argument) {
for (;
{
osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */
LED_On (LED_B);
signal_func(tid_phaseC); /* call common signal function */
LED_Off(LED_B);
}
}
/*----------------------------------------------------------------------------
* Thread 3 'phaseC': Phase C output
*---------------------------------------------------------------------------*/
void phaseC (void const *argument) {
for (;
{
osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */
LED_On (LED_C);
signal_func(tid_phaseA); /* call common signal function */
LED_Off(LED_C);
}
}
/*----------------------------------------------------------------------------
* Thread 5 'clock': Signal Clock
*---------------------------------------------------------------------------*/
void clock (void const *argument) {
for (;
{
osSignalWait(0x0100, osWaitForever); /* wait for an event flag 0x0100 */
LED_On (LED_CLK);
osDelay(80); /* delay 80ms */
LED_Off(LED_CLK);
}
}
osThreadDef(phaseA, osPriorityNormal, 1, 0);
osThreadDef(phaseB, osPriorityNormal, 1, 0);
osThreadDef(phaseC, osPriorityNormal, 1, 0);
osThreadDef(clock, osPriorityNormal, 1, 0);
/*----------------------------------------------------------------------------
* Main: Initialize and start RTX Kernel
*---------------------------------------------------------------------------*/
int main (void) {
SystemCoreClockUpdate();
LED_Initialize(); /* Initialize the LEDs */
tid_phaseA = osThreadCreate(osThread(phaseA), NULL);
tid_phaseB = osThreadCreate(osThread(phaseB), NULL);
tid_phaseC = osThreadCreate(osThread(phaseC), NULL);
tid_clock = osThreadCreate(osThread(clock), NULL);
osSignalSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */
osDelay(osWaitForever);
while(1);
}