Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Hardfault (usagefault) exception while switching between threads - Processor switching to ARM state

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Hardfault (usagefault) exception while switching between threads - Processor switching to ARM state
Moderator:
ANCY

Post Reply
Follow this topic



Hardfault (usagefault) exception while switching between threads - Processor switching to ARM state

ArunSP posted on 02 Jul 2012 3:35 PM PST

1 Forum Post

Iam working on porting an OS to Cypress - CY8C55 - AXI 060. Im using PSOC5 creator as the IDE and GNU GCC 4.4.1 tools for compiling.

I created  few threads of same priority: a simple thread which sends serial messages(UART send by polling).

First, a thread (say thread A) runs for its time slice followed by, the next thread (say thread B) running for its time slice. When the thread B completes its running and context switches to the third thread (say thread C), hard fault exception occurs.

Register Values dumped in Hardfault handler as suggested by Joseph Yiu http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/ :

R0 = d;      R1 = 1;      R2 = 9;      R3 = 0;      R12 = 81f4
LR [R14] = 0  subroutine call return address;      PC [R15] = 0  program counter;      PSR = 60000000
BFAR = e000ed38;    CFSR = 20000;    HFSR = 40000000;    DFSR = 0;    AFSR = 0;     BFSR = 200
UFSR = 2;    MMFSR = 20000;    CCR = 200;    SCB_SHCSR = 0;

In the hardfault region i also dumped the stack region around stack pointer of processor saved registers:

Memory - Value 
1fff9c30 - d;
1fff9c34 - 1; 
1fff9c38 - 9;
1fff9c3c - 81f4;  
1fff9c40 - 8200;
1fff9c44 - 24db;
1fff9c48 - 40c;
1fff9c4c - 61000000;

From the dumped register values, i noticed that xPSR value is 60000000. In cortex M3 TRM, it says 24th bit (the Thumb bit)should always be 1(thumb state), otherwise it would cause an usage fault exception.

For us, the Thumb bit is cleared , while thread switching happens, which is evident from the register value. But in the dumped memory region the value of saved xPSR value is 61000000. I couldnt figure out what causes this bit in the xPSR register to change from 1 to 0.

I would highly appreciate your efforts to support us.




Re: Hardfault (usagefault) exception while switching between threads - Processor switching to ARM state

LookAtSystemSolutions posted on 04 Jul 2012 08:43 PM PST
Top Contributor
31 Forum Posts

Let me ask a few questions

1. Did you successfully run your OS on any other Cortex-M3 device?

2. How much does your OS mess with the stack?

3. Did this OS run on any other architecture before?

In all liklyhood your issue has nothing to do with PSoC but with exception handling in the Cortex-M3. You checked for J Liu, that was a very good idea, he is extremly knowledgable about the Cortex-M.

With your information it is not possible (at least for me) to reconstruct what you might have done.

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20