Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] Unable to locate correct header files for a Freescale Kinetis microcontroller

Status
Not open for further replies.

Los Frijoles

Full Member level 1
Full Member level 1
Joined
Oct 5, 2006
Messages
98
Helped
9
Reputation
18
Reaction score
5
Trophy points
1,288
Location
Provo, Utah, United States
Visit site
Activity points
2,252
I've been working on a project of mine wherein I am using a Kinetis microcontroller.

The particular microcontroller in question is a MK20DX256VLH7, found on a Teensy 3.1 board. I've been programming for the bare metal, using some header files that I found here.

My problem is this: Those header files are wrong. I found a header file that starts with the following preamble:

Code:
/*
** ###################################################################
**     Processors:          MK20DX64VLH7
**                          MK20DX128VLH7
**                          MK20DX256VLH7
**                          MK20DX64VLK7
**                          MK20DX128VLK7
**                          MK20DX256VLK7
**                          MK20DX128VLL7
**                          MK20DX256VLL7
**                          MK20DX64VMB7
**                          MK20DX128VMB7
**                          MK20DX256VMB7
**                          MK20DX128VML7
**                          MK20DX256VML7
**
**     Compilers:           ARM Compiler
**                          Freescale C/C++ for Embedded ARM
**                          GNU C Compiler
**                          IAR ANSI C/C++ Compiler for ARM
**
**     Reference manual:    K20P144M72SF1RM Rev. 0, Nov 2011
**     Version:             rev. 1.4, 2013-06-24
**
**     Abstract:
**         This header file implements peripheral memory map for MK20D7
**         processor.
**
**     Copyright: 1997 - 2013 Freescale, Inc. All Rights Reserved.
**
**     http:                 www.freescale.com
**     mail:                 support@freescale.com
**
**     Revisions:
**     - rev. 1.0 (2012-01-15)
**         Initial public version.
**     - rev. 1.1 (2012-02-13)
**         SysTick peripheral added.
**     - rev. 1.2 (2012-04-13)
**         Added new #define symbol MCU_MEM_MAP_VERSION_MINOR.
**         Added new #define symbols <peripheralType>_BASE_PTRS.
**     - rev. 1.3 (2013-04-05)
**         Changed start of doxygen comment.
**     - rev. 1.4 (2013-06-24)
**         NV_FOPT register - NMI_DIS bit added.
**
** ###################################################################
*/

/*!
 * @file MK20D7.h
 * @version 1.4
 * @date 2013-06-24
 * @brief Peripheral memory map for MK20D7
 *
 * This header file implements peripheral memory map for MK20D7 processor.
 */

This header which claims to be authored by freescale clearly states that it covers the MK20DX256VLH7.

Now, this was working fine until I decided I had better try using some simple interrupts. I started using the PIT module to give me some interrupts like so:

Code:
...
    SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;

    // turn on PIT
    PIT_MCR = 0x00;
    // Timer 1
    PIT_LDVAL1 = 0x0003E7FF; // setup timer 1 for 256000 cycles
    PIT_TCTRL1 = PIT_TCTRL_TIE_MASK; // enable Timer 1 interrupts
    PIT_TCTRL1 |= PIT_TCTRL_TEN_MASK; // start Timer 1

    enable_irq(INT_PIT1);
    EnableInterrupts
...

EnableInterrupts is just a macro executing the appropriate assembly instruction to activate interrupts.

So, I loaded this on my teensy and...nothing happened. No interrupts were executed (I had it blinking an LED in the interrupt). I looked closer and saw that INT_PIT1 was defined as vector "85". I compared this to the K20 Sub-Family manual and found that INT_PIT1 should be 69. So, I told it to enable irq 69 and voila! It started blinking my LED.

Clearly, the header file is wrong. I see two options:

1. I rewrite the 8000 line header file. Hopefully just the IRQ's are off and not the memory locations as well.
2. Actually find some freescale-provided header files that are correct for this processor.

I'd prefer option 2, but I've been tearing my hair out trying to find a header file that will work. The ones listed in the documentation on freescale's website (under snippets) are just for the *DZ10 series of the Kinetis K-series. Further, the ones in the file referenced by the site I referenced earlier are also wrong.

The only file I can find that is correct is the one that comes with the teensyduino software provided by PJRC (who makes the Teensy 3.1). The problem with using this file is that I would need to rewrite the crt0.S file that I'm using to match the names of the ISRs that it uses (which isn't a terrible task, but I'd like to avoid it).

Where do I find this sort of documentation? Do I need to call Freescale? Can I only get this stuff if I'm a company purchasing in bulk?

I'm willing to rewrite stuff to work (and I don't consider it difficult...just inconvenient), but I'd really prefer to get something from the manufacturer.
 

Hi

the attached Archive contains 2 files :

MK20D7.H : which i think is the file you are looking for.
system_MK20D7.h : rovides a system configuration function & ...

Both Files are From Keil Package that you can download for free(Compiler up to 32kb).For updated files you should download specific CPU Packs.

the first file also available here :
https://www.keil.com/dd/docs/arm/freescale/kinetis/mk20d7.h

You may also download Kinetics Design Studio from Free Scale and extract the required files from the package:

https://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KDS_IDE

Also, usually any company that manufactures the MCU, has CMSIS Library and Package and free for download.(usually with pre-built projects for multiple IDEs).

Hopefully this helps. (i'm using ST ARM MCUs in my projects and i'm not familiar with Kinetics and that all i can find)

Good Luck!
 

Attachments

  • MK20D7.zip
    49.3 KB · Views: 99

Hi,
I was also looking at the same things, but on the K20 Sub-family manual, Freescale distinquishes between interrupt vector and IRQ. In particular for PIT 1:


Address |Vector|IRQ|Src Mod|Src Desc
0x0000_0154 | 85 |69 |PIT |Channel 1


It seems IRQ is obtained by Vector-16. I still need to understand why there is a difference between int vertor and IRQ, any input is welcome.
Best,
Y
 

I did end up going with the Vector-16 method for enabling IRQs. I suspect they didn't include both the vector number and the IRQ number just to simplify things.

I know the difference comes from the fact that the 1st 16 vectors aren't controlled by the Nested Vector Interrupt Controller and are effectively always enabled, but the NVIC only has IRQs for the vectors after 16, thus the IRQ index needs to be zero for vector 16 and go up from there.

My confusion resulted from the fact that I didn't realize that they included all of those so that you could make an array of function pointers representing the vector and address them using that header. I had always defined my vector tables in assembly using .long directives, but the way they have designed their header makes it easier to do it in C as well. Another confusion resulted from the fact that the Teensyduino stuff has the IRQ's pre-adjusted and doesn't include vector numbers for the 1st 16 vectors.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top