TWR-K70F120M programming trouble

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TWR-K70F120M programming trouble

1,273 Views
alexvannewhouse
Contributor II

Howdy,

I am pretty new to programming and I have the TWR-K70F120M module. I am trying to start programming but am having trouble learning the system. Does anyone have a simple blink LED code that I can load onto the module, so I can start learning the system.

Thanks,

Alex

Labels (1)
13 Replies

995 Views
alexvannewhouse
Contributor II

Thank you Mark for all the help. I truly appreciate you taking your time to help me. I now have been able to build and compile the code, but nothing happens(no LED blinks or anything). I have defined BLINKY, but still can't seem to find the problem. Any suggestions? Also, where is the actual code for the blinking LED and what LED exactly is supposed to be blinking? The comment says the "heartbeat LED". The STATUS,TPWR, and PWR LEDs are the only ones on,  I included console window after I compiled the code and configurations that I set up today. Sorry for all the trouble, but I am at a total loss. 

Thank you,

Alex 

Error6.PNG

0 Kudos

995 Views
mjbcswitzerland
Specialist V

Alex

It looks like you have set up the debug target correctly and there is code running.
The LED that flashes is the one in the touch sensor area (red I think) closest to the blue push button switches (see the simulation screen shot).

The code responsible for flashing the LED is in the file Watchdog.c. It looks like this:

extern void fnTaskWatchdog(TTASKTABLE *ptrTaskTable)   // watchdog called regularly
{
    fnRetriggerWatchdog();                             // hardware dependent
}

This is a task that is scheduled every 200ms which re-triggers the watchdog. The routine fnRetriggerWatchdog() has a call
    TOGGLE_WATCHDOG_LED();           // optionally flash a watchdog (heart-beat) LED
which can be assigned to an output. In the case of the TWR-K70F120M this is
_TOGGLE_PORT(C, BLINK_LED), which toggles PTC9.

Regards

Mark

0 Kudos

995 Views
mjbcswitzerland
Specialist V

Alex

What hasn't been mentioned yet is that the Kinetis parts have various clocking option which need to match with the HW.
I assume that you use the TWR-K70F120M board as part of the tower kit, with the TWR-SER module and in this configuration it is typical to clock the K70 from the 50MHz oscillator supplied by the TWR-SER board (which then allows Ethernet operation). The configuration also defaults to this technique if not adjusted for others.

Therefore I recommend that you also check jumper settings according to chapter 7 of this guide: http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf

Regards

Mark

0 Kudos

995 Views
alexvannewhouse
Contributor II

Howdy Mark,

I am using the TWR-K70F120M board by itself. I do not have the TWR-SER.

Thanks,

Alex

0 Kudos

995 Views
mjbcswitzerland
Specialist V

Alex

Without the TWR-SER the TWR-K70F120M is fairly limited.
However, if you set jumpers J19 and J18 1-2 on the board it will connect its local 50Mhz oscillator to PTA18, its EXTAL input, to give the matching clock configuration.

Regards

Mark

0 Kudos

995 Views
alexvannewhouse
Contributor II

Howdy Mark.

Thank you again for all the help. I was able to finally get it to work with your help. I do have another question for you though. Are there any pins on the TWR-K70F120M board that can be used as ADC Inputs from an external source? I am running the ADC Demo that uses the potentiometer and added a section that turned on an LED when the value got within a certain range. I now wish to input analog values from a different device into this board and have the same function. Would pads A29 & A30 which are ADC1_DM0 and ADC1_DP0, respectively work for this function?

Thanks,

Alex VanNewhouse

0 Kudos

995 Views
mjbcswitzerland
Specialist V

Hi Alex

If I understand correctly you have used the ADC's range triggering capabilities and the code below:

    adc_setup.int_adc_controller = 1;                                    // ADC controller 1
    adc_setup.int_adc_bit = ADC_DM1_SINGLE;                              // ADC DM1 single-ended
    adc_setup.int_adc_int_type = (ADC_LOW_LIMIT_INT | ADC_HIGH_LIMIT_INT); // interrupt type (trigger only when lower or higher than defined levels)
    adc_setup.int_low_level_trigger = (unsigned short)(ADC_VOLT * 1.3);  // the low level trigger threshold represented as input voltage (note: setting low threshold higher than the high threshold causes a trigger inside the range rather than outside of it)
    adc_setup.int_high_level_trigger = (unsigned short)(ADC_VOLT * 2.6); // the high level trigger threshold represented as input voltage
    adc_setup.int_handler = adc_range;                                   // handling function
    fnConfigureInterrupt((void *)&adc_setup);                            // start operation now

which monitors the input called ADC_DM1_SINGLE (connected to the potentiometer on the TWR-K70F120M board).

To change this to the other inputs that you refer to adc_setup.int_adc_bit can be set to ADC_DM0_SINGLE or ADC_DP0_SINGLE respectively. Note that each ADC (0..3 in the K70) can monitor one such input so you could have up to 4 inputs being level/range-monitored at any time without the processor needing to do any work. When any range trigger occurs the corresponding interrupt will fire.

Some more ADC/DAC information is available in the document http://www.utasker.com/docs/uTasker/uTaskerADC.pdf

Regards

Mark

0 Kudos

995 Views
alexvannewhouse
Contributor II

Howdy Mark,

So I was able to make the changes that you told me to perform specifically for the TWR-K70F120M, but I am still collecting a few errors. One was a definition error that is being drawn from an inclusion that comes from an else statement that isn't being used so I was thinking of adding the definition to the if statement. When I added the definition to the if statement, it got rid of all errors, but the program would not execute when trying to debug. Thanks for your help.

Error4.PNG

Error from else statement.

Error5.PNG

Excute error after adding definition.

Thanks,

Alex

0 Kudos

995 Views
mjbcswitzerland
Specialist V

Alex

I have attached config.h set up for TWR-K70F120M (and simple BLINKY case).

The problem that you had was that NUMBER_I2C was not defined in the Blinky case when I2C was still enabled. The solution was to either disable I2C of add the define. This was not your error since it was like that in the open source version but I just updated it so that the define is never missing.

I didn't see what you changed and can't explain the Eclipse error that you then have.

Use the attached file to be sure and if you continue to have problems debugging, try following the method in the video at https://www.youtube.com/watch?v=bilc_4Cr7eo (from about 14:00)

Good luck

Regards

Mark

0 Kudos

995 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Alex,

I checked you have submit the same question in two places, I reply you on that thread:

https://community.nxp.com/thread/461164  

BR

Alice

0 Kudos

995 Views
mjbcswitzerland
Specialist V


Alex

It is better to show the console window output because it then shows the exact error rather than just the general error category.

However, it is possible that you have set two target boards at the same time - I see that the build is triggering an error because you are building for 60MHz bus clock and the environment sees that the target processor can't operate at this speed. It is generating a build error in preference to the object being generated and then not operating properly on the target (which could cause lots of loss of time if it were the case trying to work out why it doesn't run or is unreliable). Since the TWR-K70F120M can run at 60MHz bus clock I assume that another processor type is being selected (which can happen when two targets are chosen at the same time).

This is how to configure exactly for the TWR-K70F120M in KDS.
1. Import the project
2. In \Applications\uTaskerV1.4\config.h
- select #define BLINKEY to get the simplest project configuration
- disable #define FRDM_K64F (or whatever other board target is selected that you don't want to use)
- enable #define TWR_K70F120M
3. In the KDS build settings choose "cortex-m4" at core. You can also (optionally) select "FP instructions (hard)" and FPU type "fpv4-sp-d16" since this device has FPU (the second is selected automatically when the first is chosen). However, if moving to a cortex-m0+ type later this must 'first' be disabled otherwise a KDS error occurs since it grays out the FPU field and it can't be deselected (and nothing runs).
4. Use the linker script file K_1M_128.ld
5. Build the target "uTasker_V1.4_Flash"

Once you are are happy with the simple case you can remove BLINKY and do more interesting things (USB, SD card, TCP/IP etc.).

Also try building with VisualStudio (free community edition can be used) because you can also build with GCC from its make file. Then you can see the TWR-K70F120M being simulated in (approx.) real time [see below] as well as quickly generate binary files for the board. You can then change HW targets to build and simulate almost any other board without needing the HW.

Tr y writing, testing and debugging your own code extensions in the simulator to use grea tly more power ful and effic ient develop ment and debugging cap abilities that on the HW with K DS. This will allow you to analyse and progress many times faster than others who stick to and are restricted to the traditional techniques.

Regards

Mark

pastedImage_1.png

995 Views
mjbcswitzerland
Specialist V

Hi Alex

If you download the open source uTasker project from the link below you can use it on the TWR-K70F120M, starting with a blinking LED.
Just select the define TWR_K70F120M for your board and the define BLINKEY to get the simple flashing LED. You can use almost any IDE to do this (KDS, CW, MCUXpresso, IAR, Keil, Rowley, etc.) and also run it in the Visual Studio as (real-time) K70 simulation.
Then you can simply add more features as you wish, once you get comfortable with things - e.g. remove BLINKEY and you will have also a command line interface on the UART, add USB_INTERFACE (and chose classes) and you have a working USB stack. Add ETH_INTERFACE and you have a TCP/IP stack with various services (web server, FTP, etc.), add SDCARD_SUPPORT and you have a complete FAT file system and you can then select many other peripheral operations (timers, communication interfaces) too.

Tutorial at http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis.pdf
Various videos at https://www.youtube.com/watch?v=kWNlsAoMly4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q
Support here or at http://www.utasker.com/forum/

If you move to other Kinetis parts just select the other board in config.h and the complete project moves to that board, so one can write applications and let then run on any board that has the required peripherals without porting requirements.

The project also includes various boot loaders and, using Visual Studio, you can simulate the chip (including Flash, interrupts, DMA, Ethernet, CAN, UARTs etc..) in order to learn all details in a simple and efficient manner. For later professional designs you can use it to work much faster and to more easily achieve reliable complete solutions.

Regards

Mark


http://www.utasker.com/kinetis.html
http://www.utasker.com/kinetis/TWR-K70F120M.html

0 Kudos

995 Views
alexvannewhouse
Contributor II

Hey Mark

Thank you for the useful links. There was a link to a video in the main uTasker readme file that explained how to set up the project in KDS. All was going well until I reached the part about changing the linker scripts. I ultimately changed it to say "${uTaskerLinkerScripts}/K_512_128.ld" in the file path under General under Cross ARM C++ Linker in the C/C++ Settings for the project. After changing that, I got several errors that I have attached to this post. Do you know what could be causing these errors? Thank you for any help.

Best regards,

Alex

Error1.PNG

Error2.PNG

0 Kudos