K40 newbee questions

cancel
Showing results for 
Search instead for 
Did you mean: 

K40 newbee questions

Jump to solution
1,356 Views
GerasinIvan
Contributor II

Hi all, i have some questions, could you help me? //And sorry for my english

1) I'm trying to understand tutorials for k40 and in all tutorials i saw 'k40_TOWER_BOARD_SUPPORT.h'/'k40_TOWER_BOARD_SUPPORT.c'

where can i find that sources?

2) What mean 'PORT_PCR_MUX(1)'?

Thnx for helping.

Labels (1)
0 Kudos
1 Solution
500 Views
adriansc
Contributor IV

Hi Gerasin,

Answering your second question PORT_PCR_MUX(1) is a mask which writes to the MUX field on PCR register. Look for Pin Control Register n (PORTx_PCRn) in the Reference Manual. In MUX field you can write from 0 to 7 in order to select Alternative number.

In section K40 Signal Multiplexing and Pin Assignments you can see the function for each Alternative (ALTx), in this case writing 1 (0b001) to MUX field ALT1 will be selected for that pin; for most of the pins ALT0 configures them as GPIO (GeneralPurposeInput/Output).

Answering your first question, if you can´t find those files you can create them and add them to your project:

  1. Check this link K40: Blinking LED - The Freescale Cup Wiki  where you can find the code for k40_TOWER_BOARD_SUPPORT.h and K40_TOWER_BOARD_SUPPORT.c
  2. In your project right click sources-->New-->new folder, then give a name to the folder. (e.g K40_SUPPORT).
  3. Right click on the new folder(K40_SUPPORT)-->new-->source file. Name it as K40_TOWER_BOARD_SUPPORT.c
  4. To the same of the last step, but now choosing header file and name it as k40_TOWER_BOARD_SUPPORT.h

    adding .c and .h files.JPG

  5. In .h file paste the code form the link and do the same with .c file. Copy the code respectively.
  6. Now you just need to write the #include files in each one.
  7. Modify function main.
  8. Add paths for the new folder in project properties. right click-->properties

    adding paths 1.JPG

  9. In the tree on your left  C/C++ Build-->Settings then add the paths on ARM Compiler-->Input. Add the path for Source folder "${ProjDirPath}/Sources"adding paths 2.JPG
  10. Apply and Now compile.

Let me know if you have any problems.

Hope this helps.

View solution in original post

0 Kudos
10 Replies
500 Views
GerasinIvan
Contributor II

I have another stupid question: how to burn/"save" program to k40, so after reset or turn off-on k40, program will start again? Autonomous work , i mean. And what typical solution about autonomous power supply?

0 Kudos
500 Views
adriansc
Contributor IV

Hi,

You need compile you code in Flash mode. In Flash memory your application will be there after power-up again. Check the image below:

flashram.png

Click on the name of the project and then this will show up.

You can check datasheet of your product and see the list of power options, you can use the USB input to power on.

500 Views
GerasinIvan
Contributor II

I tried it, but it does not work.

0 Kudos
500 Views
adriansc
Contributor IV

Hi,

I assume that you are using for your project the Codewarrior´s console, you can see it in debug mode , it is in the lower part of the window; it shows what printf returns. So when you disconnect the board and try autonomous mode it is looking for the Codewarrior´s console and never find it.

If you are using printf in your project and really don´t need it for autonomous behavior just erase them, maybe that is happening.

Hope this helps.

0 Kudos
500 Views
yasararafath
Contributor II

I have followed the steps above . But it is not working in power on reset ie once when we unplug and replug the power to the kwikstik k40 Board.

Reply me soon if anyone can pls....

0 Kudos
500 Views
JimDon
Senior Contributor III

Did you unplug the debug BDM? I have seen it where it hols the board reset.

0 Kudos
500 Views
yasararafath
Contributor II

Friend, I cant understand BDM. Is it Background Debug Mode? Then how to unplug that BDM. Pls reply me soon

0 Kudos
500 Views
GerasinIvan
Contributor II

Thank you, it really helpful.

But i have another problem with line scan camera tutorial, and then i starts programm, it doesn't work, and return: "No source available for "0xFFFFFFFE (0xFFFFFFFE)() " "

In assambley code last strokes:

fffffff6:   .short 0xbabababa

fffffffa:   .short 0xbabababa

fffffffe:   Unable to retrieve disassembly data from backend.

ffffffff:   Unable to retrieve disassembly data from backend.

I think it's not correct, but i havo no idea how to fix it.

0 Kudos
500 Views
adriansc
Contributor IV

Hi,

I have never experienced that issue, but try to look for this problem in some threads of the community. In this one you can find some tips to solve it:  unable to debug in my MCU (kenetis k53 )

Hope this helps.

501 Views
adriansc
Contributor IV

Hi Gerasin,

Answering your second question PORT_PCR_MUX(1) is a mask which writes to the MUX field on PCR register. Look for Pin Control Register n (PORTx_PCRn) in the Reference Manual. In MUX field you can write from 0 to 7 in order to select Alternative number.

In section K40 Signal Multiplexing and Pin Assignments you can see the function for each Alternative (ALTx), in this case writing 1 (0b001) to MUX field ALT1 will be selected for that pin; for most of the pins ALT0 configures them as GPIO (GeneralPurposeInput/Output).

Answering your first question, if you can´t find those files you can create them and add them to your project:

  1. Check this link K40: Blinking LED - The Freescale Cup Wiki  where you can find the code for k40_TOWER_BOARD_SUPPORT.h and K40_TOWER_BOARD_SUPPORT.c
  2. In your project right click sources-->New-->new folder, then give a name to the folder. (e.g K40_SUPPORT).
  3. Right click on the new folder(K40_SUPPORT)-->new-->source file. Name it as K40_TOWER_BOARD_SUPPORT.c
  4. To the same of the last step, but now choosing header file and name it as k40_TOWER_BOARD_SUPPORT.h

    adding .c and .h files.JPG

  5. In .h file paste the code form the link and do the same with .c file. Copy the code respectively.
  6. Now you just need to write the #include files in each one.
  7. Modify function main.
  8. Add paths for the new folder in project properties. right click-->properties

    adding paths 1.JPG

  9. In the tree on your left  C/C++ Build-->Settings then add the paths on ARM Compiler-->Input. Add the path for Source folder "${ProjDirPath}/Sources"adding paths 2.JPG
  10. Apply and Now compile.

Let me know if you have any problems.

Hope this helps.

0 Kudos