Hard Fault on SEMA4 CP1INE access?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Hard Fault on SEMA4 CP1INE access?

跳至解决方案
1,072 次查看
eruanno
Contributor I

Hello,

I would like to run a simple application that uses hardware semaphores on phyCore board (Vybrid PVF65GS10CMK40 test rev.). I have a problem with

modifying CP1INE register. Whatever I do, any write access to this register causes Hard Fault.

This is a code sample:

#define GATE (*(volatile unsigned char*)(0x4001D000))

#define CPINE (*(volatile unsigned short*)(0x4001D048))

int main()

{

     SystemInit();          // Sets vector table and  enables all peripheral clocks excepting GPU

     CPINE = 0x1000;

     GATE = 2;

    

     while(1)

     {

     }

}

0 项奖励
回复
1 解答
895 次查看
simonkunzmann
Contributor II

Hi Matthew,

I had the same problem and this was the solution:

The Reference Manual states that the offset to the SEMA4_CP1INE Register is 48, but when i take a look at the SEMA4_MemMap struct  in the "MVF50GS10MK50.h" file the offset seems to be  50:

  1. /** SEMA4 - Peripheral register structure */ 
  2. typedef struct SEMA4_MemMap { 
  3.   uint8_t GATE[16]; 
  4.   uint8_t RESERVED_0[50]; /* 48 */ 
  5.   uint16_t CP0INE;                                 /**< Semaphores Processor n IRQ Notification Enable, offset: 0x40 */ 
  6.   uint8_t RESERVED_1[6]; 
  7.   uint16_t CP1INE;                                 /**< Semaphores Processor n IRQ Notification Enable, offset: 0x48 */ 
  8.   uint8_t RESERVED_2[54]; 
  9.   uint16_t CP0NTF;                                 /**< Semaphores Processor n IRQ Notification, offset: 0x80 */ 
  10.   uint8_t RESERVED_3[6]; 
  11.   uint16_t CP1NTF;                                 /**< Semaphores Processor n IRQ Notification, offset: 0x88 */ 
  12.   uint8_t RESERVED_4[118]; 
  13.   uint16_t RSTGT;                                  /**< Semaphores (Secure) Reset Gate n, offset: 0x100 */ 
  14.   uint8_t RESERVED_5[2]; 
  15.   uint16_t RSTNTF;                                 /**< Semaphores (Secure) Reset IRQ Notification, offset: 0x104 */ 
  16. } volatile *SEMA4_MemMapPtr; 

maybe this helps.

Best Regards

Simon

在原帖中查看解决方案

0 项奖励
回复
5 回复数
896 次查看
simonkunzmann
Contributor II

Hi Matthew,

I had the same problem and this was the solution:

The Reference Manual states that the offset to the SEMA4_CP1INE Register is 48, but when i take a look at the SEMA4_MemMap struct  in the "MVF50GS10MK50.h" file the offset seems to be  50:

  1. /** SEMA4 - Peripheral register structure */ 
  2. typedef struct SEMA4_MemMap { 
  3.   uint8_t GATE[16]; 
  4.   uint8_t RESERVED_0[50]; /* 48 */ 
  5.   uint16_t CP0INE;                                 /**< Semaphores Processor n IRQ Notification Enable, offset: 0x40 */ 
  6.   uint8_t RESERVED_1[6]; 
  7.   uint16_t CP1INE;                                 /**< Semaphores Processor n IRQ Notification Enable, offset: 0x48 */ 
  8.   uint8_t RESERVED_2[54]; 
  9.   uint16_t CP0NTF;                                 /**< Semaphores Processor n IRQ Notification, offset: 0x80 */ 
  10.   uint8_t RESERVED_3[6]; 
  11.   uint16_t CP1NTF;                                 /**< Semaphores Processor n IRQ Notification, offset: 0x88 */ 
  12.   uint8_t RESERVED_4[118]; 
  13.   uint16_t RSTGT;                                  /**< Semaphores (Secure) Reset Gate n, offset: 0x100 */ 
  14.   uint8_t RESERVED_5[2]; 
  15.   uint16_t RSTNTF;                                 /**< Semaphores (Secure) Reset IRQ Notification, offset: 0x104 */ 
  16. } volatile *SEMA4_MemMapPtr; 

maybe this helps.

Best Regards

Simon

0 项奖励
回复
895 次查看
eruanno
Contributor I

Hi Simon,

It seems to work now! Thanks for help.

Best regards

Matthew

0 项奖励
回复
895 次查看
eruanno
Contributor I

I am sorry, out of habit, I have pressed Ctrl+S and that caused sending my question :smileyhappy: before I finished writing it. More details here:

This is an excerpt from disassembly. As you can see I use 16-bit access to write CP1INE. Read access does not cause Hard Fault.

0x3F00037C : LDR      r0,[pc,#32] ; [0x3F0003A0] = 0x4001D000

0x3F00037E : MOV      r1,#0x1000

0x3F000382 : STRH     r1,[r0,#0x48]

0x3F000386 : MOVS     r1,#2

0x3F000388 : STRB     r1,[r0,#0]

Besides on HardFault CFSR is set to 0x00000400 (IMPRECISERR).

Did I miss something? May it be a silicon bug (eventually this is test PF revision)?

Thanks in advance.

0 项奖励
回复
895 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi Matthew,

I have seen that the most common reason that generates a hard fault is trying to write to a module whose clock gate is off.

Make sure that the correct CCM_CCPGRn bits and register is set for the SEMA4 module.

I hope that helps,

Alejandro

0 项奖励
回复
895 次查看
eruanno
Contributor I

Hi Alejandro,

Thanks for reply. I was able to lock the gates by writing the core number + 1 to GATE registers so SEMA4 module clock was on. I have not modified CCPGR bits as they are set after reset by default.

The Simon's hint was good direction to solve the problem.

Best regards,

Matthew

0 项奖励
回复