Kinetis K10 RTC problem

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

Kinetis K10 RTC problem

Jump to solution
3,911 Views
tomasjakubik
Contributor I

Hello,

I have my custom board with MK10DN512Z. I use CW 10.2 on Ubuntu Linux and Kwikstik's J-Link to debug.

On XTAL32 and EXTAL32 pins is 32.768kHz,6pF crystal. I Enabled RTC oscilator in Processor Expert with the same frequency and 12pF Capacitor load. Now MCU goes into unhandled interrupt immediately after reset.

Debug is stuck here:

PE_ISR(Cpu_Interrupt)

{

  /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */

  PE_DEBUGHALT();

}

with Cpu_Interrupt = 0x00001DF4. I think interrupt vector table ends at 0x000001DC, right? When main crystal didn't work, processor waited in an infinite loop, so I think this problem is not electrical.

What that could mean? I'm newbie with Freescale nad Processor Expert, so I might be missing something simple. Has anyone any idea, how to fix it and run RTC oscillator?

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
1,673 Views
MVa
NXP Employee
NXP Employee

Hi,
  this can be caused by low or no voltage on VBAT pin.

 

From reference manual:

Any attempt to access an RTC register (except the access control registers) when VBAT

is powered down, when the RTC is electrically isolated, or when VBAT POR is asserted,

will result in a bus error.

MVa

View solution in original post

0 Kudos
Reply
6 Replies
1,673 Views
BlackNight
NXP Employee
NXP Employee

Hello,

the first thing to find out is: which exception has caused this?

Have a look at Oh my! An Interrupt | MCU on Eclipse  how to create a handler for every interrupt vector ('own hander for every interrupt').

This will hopefully tell you what is causing the exception.

0 Kudos
Reply
1,673 Views
tomasjakubik
Contributor I

Thanks, that was helpful. Now I know it was Cpu_ivINT_Hard_Fault interrupt. After reset I unchecked "Run out of reset" and found that it happens in __init_hardware(). On line:

if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u) { /* Only if the OSCILLATOR is not already enabled */

Dissasembly shows:

  movw r0,#0xd010

  movt r0,#0x4003

  ldr r0,[r0,#0]

  and r0,r0,#0x100

  cmp r0,#0

  bne __init_hardware+0x70 (0x2030); 0x00002030

Arrow points last to ldr r0,[r0,#0] and next it is in hardfault handler. I don't know much about Cortex assembly, but it should work. Same thing happens whnever I want to read RTC_CR. RTC_CR is at 0x4003d010 by datasheet, but is it possible this adress is wrong?

0 Kudos
Reply
1,673 Views
BlackNight
NXP Employee
NXP Employee

maybe this thread might be helpful:

https://community.freescale.com/message/308944#308944

0 Kudos
Reply
1,673 Views
tomasjakubik
Contributor I

I know processor exits on ldr instruction with right address in r register. I have even tried calling ldr in supervisor mode with the same result. Is there any reason why simple ldr instruction should interrupt with hardfault? Looks like RTC_CR doesn't exist in this processor.

RTC on multiple processors seems to be little quirky. There is errata for mask 4N30D:

  • e2576: RTC: When the RTC is configured to allow supervisor access only, the write and read access registers can be modified in user mode
  • Errata type: Errata
  • Description: When the RTC is configured to allow supervisor access only, the write and read access registers can be modified in user mode. A bus error is still generated.
  • Workaround: RTC supervisor mode access only option is not supported.

Perhaps that is why PE doesn't bother with setting SUP bit even though reset state is supervisor mode write access only. Either way, reading should work in both modes. Unless there is some other error yet undocumented in errata.

0 Kudos
Reply
1,674 Views
MVa
NXP Employee
NXP Employee

Hi,
  this can be caused by low or no voltage on VBAT pin.

 

From reference manual:

Any attempt to access an RTC register (except the access control registers) when VBAT

is powered down, when the RTC is electrically isolated, or when VBAT POR is asserted,

will result in a bus error.

MVa

0 Kudos
Reply
1,673 Views
tomasjakubik
Contributor I

Thank you,

I have connected Vcc and Vbat and RTC is running.

I should have read more carefuly. You must hear that a lot here :smileyhappy:.

Thanks a lot, Tomas

0 Kudos
Reply