µTasker Forum

µTasker Forum => µTasker general => Topic started by: ABBASID on June 06, 2021, 07:56:38 AM

Title: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: ABBASID on June 06, 2021, 07:56:38 AM
I have successfuly run Keil MDK codes provided in "SDK_2.2.0_TWR-K60D100M_board" on TWR-K60D100M-KIT. Now I am trying to write codes for my own design circuit which uses MK60DX256VLL10. In sample code of GPIO, PORTA11 in TWR-K60D100M is used to toggle LED on/off. Now in my own design circuit, same pin PORTA11 is used to toggle LED on/off. The problem is that the code is built successfuly in KEIL MDK 5.34 but when I press the debug button, the code debugs but instead of normal procedure (in which when debug is pressed, code enters in debug mode and you have to press RUN to run the code on your target ) the code shows RUN button as gray (as if without pressing the RUN button, code has entered RUN mode) but nothing happens on design circuit and when I press STOP button, the error appears ( error message is typed in bold as below to distiguish from my question)

Cannot access memory @0x2000fff8, Read, Acc Size: 4 Byte

Cannot access memory @0x2000fffc, Read, Acc Size: 4 Byte

'

'

'

Cannot access memory @0x20011f94, Read, Acc Size: 4 Byte



I have tried to undesrstand this error. 20011f94 minus 2000fff8 = 1F9C = 8092 (decimal) = 8K memory.


Can anybody help me understand this error. Are there any special setting to change in code when exporting from TWR-K60D100M to  MK60DX256VLL10 (apart from target selection in Keil MDK). Project/Code is attached whic is very simple to understand so please have look at it.
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: mark on June 06, 2021, 04:57:24 PM
Hi

The K60DN512VMD10 on the TWR-K60D100M has 512k Flash and 128k SRAM, whereby the SRAM occupies the memory space 0x1fff0000 ... 0x2000ffff

Your HW has the K60DX256, which has 256k Flash and 64k SRAM, where the SRAM occupies the memory space 0x1fff8000 ... 0x20007ffff

Any reads outside of SRAM space will result in an error. The addresses signalling errors are from 0x2000fff8 which is not in the memory range of the K60DX256 (although is in the range of the K60DN512VMD10 ).

Therefore it is normal that it errors if you use the same memory layout as the K60DN512VMD10 and means that you need to adjust your linker script file to match the part being used.

Regards

Mark
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: ABBASID on June 06, 2021, 07:07:24 PM
When target is selected in Keil MDK it automatically adjust these things. Is this not the case? Attached two pictures show that the difference which you are suggesting is there when MK60DN512VMD10 is selected (which is used in development kit) as comapred to MK60DX256VLL10 (used in my circuit). Are there any other settings which needs changing in the code? Is this setting in Keil MDK's target selection enough? If there are changes needed to be done in the code, would you be so kind to point me in that direction.
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: mark on June 07, 2021, 02:18:06 AM
Hi

You need to check the linker setting because it defines whether these settings are used or setting from the link script instead.

Regards

Mark
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: ABBASID on June 07, 2021, 06:59:05 PM
Where can I find these settings in Keil MDk software?
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: mark on June 07, 2021, 09:02:07 PM
In the Linker tab/register
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: ABBASID on June 16, 2021, 04:24:55 PM
Thank you for your help. It was really helpful.

In the .scf file, following modifications were made;

#define m_interrupts_ram_start 0x1FFF8000
#define m_interrupts_ram_size __ram_vector_table_size__

#define m_data_start (m_interrupts_ram_start + m_interrupts_ram_size)
#define m_data_size (0x00008000 - m_interrupts_ram_size)

#define m_data_2_start 0x20000000
#define m_data_2_size 0x00008000

After this, code ran successfuly.
Title: Re: Kinetis K60: code imported from TWR-K60D100M to circuit using MK60DX256VLL10
Post by: mark on June 16, 2021, 05:44:09 PM
 ;)