.elf file generated in arduino for MK20DX256VLH7 is not working.

Status
Not open for further replies.

npashine

Well-known member
Hi all,

I've generated a simple blinky example .elf file and I'm trying to burn the MK20DX256VLH7 form Keil via SWD mode through Ulink2 and it's not functioning as expected.

In an example, the LED(13) is glowing which is connected with IC Pin 50.

Keil burns .axf which is .elf form.

Also, the example program of Keil is working fine when burned via the same manner.

Kindly tell what changes I have to do or if any wrong I'm doing.
 
Difficult to tell without more detailed information since most people here will not be aware about the default libraries used by Keil instead of those which are delivered with the Teensyduino environment and used by the vast majority of forum users:

Forum Rule: Always post complete source code & details to reproduce any issue! (see top of page)
 
In Keil, I'm making a dummy project just burning the .elf file after changing the extension to .axf.
.axf glows the PTC9 and PTC10, pin 55 and 54.

Kindly let me know what information you need so that I can able to gather and share.
 
Does the same elf file load and work correctly when burnt with the Teensyduino loader? With which Arduino/Teensyduino version did you compile it? Which processor/speed did you select for compiling? Did you use the default "blinky" example or did you modify the source code?

You say that it "glows" PTC9 and PTC10, does "glow" mean there is a very rapid blinking? What does your oscilloscope/logic analyzer say?
 
-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);
}
 
What I don't understand: Why do you use Keil? What do you want to achieve which can not be done with Teensyduino? I fear that most people here, including me, have zero experience with Keil and their associated H/W driver libraries.
 
Maybe try using the HEX file instead of the ELF?

Or buy a genuine Teensy 3.2 and let Teensy Loader do the work of getting the code programmed into the chip.
 
If everybody did that, there would not longer be a viable commercial model for PJRC and its excellent hardware, software and customer support...
 
Hi Theremingenieur,

I'm just trying to achieve the same result with alternate methods available(No Intension to harm PJRC).
Apologies if i did.
 
I already bought many teensy's and now I want to remove dependencies.

Teensy is designed so you can use your .HEX file directly on NXP (formerly Freescale) MK20DX256 chips.

But if you're using someone else's products to get the known-good hex file programmed, and they're not working, you really need to get technical support from the company that provided those tools. You need to contact Keil for help with their tools. This forum is *not* the appropriate place to ask for help with Keil's tools for the purpose of not buying anything from PJRC.

If Keil can't help you, perhaps buy a programmer from P&E Micro (and ask them for support).

Or you might contact your distributor where you're buying the MK20 chip, or other distributors who sell it. Some of them offer programming service, where they'll pre-program your HEX file into the chips.

I want to emphasize again, these tools and services are not from PJRC. You really must seek support from those companies.
 
Status
Not open for further replies.
Back
Top