Author Topic: initialisation fails at fnGetRndHW() routine  (Read 2758 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
initialisation fails at fnGetRndHW() routine
« on: July 28, 2020, 08:06:10 PM »
Hi Mark
   I have a new board with a MCF52259 processor (same as I have used for years), but this one is crashing at he below function (I have removed here the other instructions and left the one causing the issue.:

extern void fnInitialiseRND(unsigned short *usSeedValue)                 // {84}
{
    if ((*usSeedValue = *ptrSeed) == 0) {                                // we hope that the content of the random seed is random after a power up
        *usSeedValue = 0x127b;                                           // we must not set a zero - so we set a fixed value
    }                                                                    // after a reset it should be well random since it will contain the value at the reset time

}

As soon as I go into the line:    if ((*usSeedValue = *ptrSeed) == 0) {   

I get an undefined interupt:

static __interrupt__ void undef_int(void)
{
    while (1) {}                                                         // wait here and analyse with debugger....
}

Any pointers what can cause this?

Best Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: initialisation fails at fnGetRndHW() routine
« Reply #1 on: July 28, 2020, 11:28:10 PM »
Hi Neil

Since the RNG initialisation is called very early on in the code there are probably no hard fault handlers installed yet and a hard fault may be handled as an undefined interrupt.

What values do you find for usSeedValue pointer and ptrSeed? If one of these is invalid it will result in a hard fault.

The MCF52259 has a HW random number generator too and so I wouldn't normally expect the SW RNG to be used - I would expect
#define RND_HW_SUPPORT                                               // enable the use of the hardware resources in this chip
to be enabled for this device (in app_hw_m5223x.h)

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: initialisation fails at fnGetRndHW() routine
« Reply #2 on: July 29, 2020, 11:45:58 AM »
Hi Mark
  For some reason the processor and external ram was faulty.  Changed both and cleared the issue.

I made sure the #define RND_HW_SUPPORT   was enabled.

Many thanks
Neil