Hello everyone.
I'm using MCU KE04 series and I want write a register of CPU
For instance, the KBI0_PE (Pin Enable Register) can be found in 0x40079000 absolute address so, Can't i do this?
//////////////////////////////////////////////////////////////////////// CODE ////////////////////////////////////////////////////////////////////////
static const uint32_t BASE_ADDRESS_KBI0 = 0x40079000; //Base address
uint32_t *pointerRegister = NULL; //Initialization
pointerRegister = (BASE_ADDRESS_KBI0 + 8); //points to location fo KBI0_SC (40079008h)
*pointerRegister = 0xFEFFFFFF; //¿Write register?
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
it frozen MCU, why?¿
Solved! Go to Solution.
Richard
It depends on which KE04 you are using:
MKE04Z8VTG4(R), MKE04Z8VWJ4(R) and MKE04Z8VFK4(R) are at 0x0c
MKE04Z64VLD4(R), MKE04Z128VLD4(R),MKE04Z64VQH4(R), MKE04Z128VQH4(R), MKE04Z64VLH4(R),MKE04Z128VLH4(R), MKE04Z64VLK4(R) and MKE04Z128VLK4(R) are at 0x14
The user should not be fussed with the details if a macro is used. In the uTasker project it adapts itself automatically by
#if (defined KINETIS_KE04 && (SIZE_OF_FLASH > (8 * 1024))) || defined KINETIS_KE06 || (defined KINETIS_KEA64 && !defined KINETIS_KEAN64) || defined KINETIS_KEA128
..
#define SIM_SCGC_BME_OR (volatile unsigned long *)(SIM_BLOCK + 0x14 + BME_OR_OFFSET)
..
#else
..
#define SIM_SCGC_BME_OR (volatile unsigned long *)(SIM_BLOCK + 0x0c + BME_OR_OFFSET)
..
#endif
And the user just does
POWER_UP_ATOMIC(0, KBI0);
which transforms itself automatically to the corresponding BME code
which then works on any Kinetis part with KBI.
Non uTasker users have to carefully read the manuals and add the corresponding code manually.
Regards
Mark
Complete Kinetis solutions for professional needs, training and support:http://www.utasker.com/kinetis.html
Kinetis KE:
- http://www.utasker.com/kinetis/FRDM-KE02Z.html
- http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
- http://www.utasker.com/kinetis/FRDM-KE04Z.html
- http://www.utasker.com/kinetis/FRDM-KE06Z.html
- http://www.utasker.com/kinetis/FRDM-KE15Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Hi,
The valid register address of KBI0 is from 0x40079000 to 0x40079002, Only 3 byte. 0x40079008 is out of range. When MCU find valid address access, it will trig hardfault.
Regards,
Jing
Hi mate, thanks fro your asking,I just tried to acces 0x4007900, but i can't write it yet, Is it possible have i use the BME (Bit Manipulation Engine) module for access?
Hello Richard
Before accessing the KBI registers you need first to enable the KBI in SIM_SCGC.
Both enabling the clocks to the module and subsequent mode writes can be performed using the BME but this is not your basic issue.
Regards
Mark
Complete Kinetis solutions, training and support:http://www.utasker.com/kinetis.html
Kinetis KE:
- http://www.utasker.com/kinetis/FRDM-KE02Z.html
- http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
- http://www.utasker.com/kinetis/FRDM-KE04Z.html
- http://www.utasker.com/kinetis/FRDM-KE06Z.html
- http://www.utasker.com/kinetis/FRDM-KE15Z.html
Hi mate, thanks for your answer, That's work! it has been fixed! :smileyhappy:
Thank everyone!
Note that to enable the clock via BME the following can be used:
*SIM_SCGC_BME_OR = (SIM_SCGC_KBI0);
which on the KE04 is
*(volatile unsigned long *)(0x40048000 + 0x0c + 0x8000000) = 0x01000000;
Regards
Mark
Could you explain me how does BME work? why do you add "0x0c + 0x8000000" to "0x40048000" ?¿¿
Richard
The starting address of the SIM module is 0x40048000
The byte offset in the SIM module to the SIM_SCGC register is 0x0c, therefore its memory address is (0x40048000 + 0x0c).
The BME OR alias is an address shift of 0x80000000 therefore the OR alias of this register is at the address (0x40048000 + 0x0c + 0x80000000).
To OR 0x01000000 to the register one writes 0x01000000 to its OR alias, which gives the complete instruction.
Similarly, to AND one uses an alias offset address of 0x40000000 instead of 0x80000000, and to XOR one uses an alias offset address of 0xc0000000.
Details are also in the BME chapter of the user's manual.
Regards
Mark
Complete Kinetis solutions for professional needs, training and support:http://www.utasker.com/kinetis.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Hi Mark
mm but in the datasheet tell this:
The offset's 0x14,isn't?
Richard
It depends on which KE04 you are using:
MKE04Z8VTG4(R), MKE04Z8VWJ4(R) and MKE04Z8VFK4(R) are at 0x0c
MKE04Z64VLD4(R), MKE04Z128VLD4(R),MKE04Z64VQH4(R), MKE04Z128VQH4(R), MKE04Z64VLH4(R),MKE04Z128VLH4(R), MKE04Z64VLK4(R) and MKE04Z128VLK4(R) are at 0x14
The user should not be fussed with the details if a macro is used. In the uTasker project it adapts itself automatically by
#if (defined KINETIS_KE04 && (SIZE_OF_FLASH > (8 * 1024))) || defined KINETIS_KE06 || (defined KINETIS_KEA64 && !defined KINETIS_KEAN64) || defined KINETIS_KEA128
..
#define SIM_SCGC_BME_OR (volatile unsigned long *)(SIM_BLOCK + 0x14 + BME_OR_OFFSET)
..
#else
..
#define SIM_SCGC_BME_OR (volatile unsigned long *)(SIM_BLOCK + 0x0c + BME_OR_OFFSET)
..
#endif
And the user just does
POWER_UP_ATOMIC(0, KBI0);
which transforms itself automatically to the corresponding BME code
which then works on any Kinetis part with KBI.
Non uTasker users have to carefully read the manuals and add the corresponding code manually.
Regards
Mark
Complete Kinetis solutions for professional needs, training and support:http://www.utasker.com/kinetis.html
Kinetis KE:
- http://www.utasker.com/kinetis/FRDM-KE02Z.html
- http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
- http://www.utasker.com/kinetis/FRDM-KE04Z.html
- http://www.utasker.com/kinetis/FRDM-KE06Z.html
- http://www.utasker.com/kinetis/FRDM-KE15Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Okey, I get it!
Thanks for you time mate!
Regards