The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2016, 11:20:07 23:20


Login with username, password and session length


Pages: [1]
Print
Author Topic: dspic33f PSV page fault code  (Read 975 times)
0 Members and 1 Guest are viewing this topic.
Tupperware
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 13
-Receive: 24


« on: August 20, 2015, 09:58:47 21:58 »

Hi,

I was hoping someone may be able to help me Cool. I need to generate some C code which invokes a silicon errata issue on a dspic33fj128gp206a. I can then confirm that the compiler workaround has the desired effect.

The errata is as follows (#11 from http://ww1.microchip.com/downloads/en/DeviceDoc/80465G.pdf):

Quote
11. Module: PSV Operations
An address error trap occurs in certain addressing modes when accessing the first four bytes of an PSV page. This only occurs when using the  following addressing modes:
MOV.D
Register Indirect Addressing (word or byte mode) with pre/post-decrement

Work around
Do not perform PSV accesses to any of the first four bytes using the above addressing modes. For applications using the C language, MPLAB C30
version 3.11 or higher, provides the following command-line switch that implements a work around for the erratum.
-merrata=psv_trap

Refer to the readme.txt file in the MPLAB C30
v3.11 tool suite for further details.

So I tried some variations based on what I could find around on the internet like this:

Code:
int foo[256] __attribute__((space(psv), section("my_psv_page"))) = { };
int bar __attribute__((space(psv), section("my_psv_page")));
int x = 1;

 CORCONbits.PSV = 1;                 // ensure that PSV is enabled
 PSVPAG = __builtin_psvpage(&foo);   // set the PSVPAG correctly
                                     // for accessing foo
 if (foo[--x] == 9)           // Access with pre-decrement
 {
   result = bar;                     // we know bar is in the same
                                     // PSV page as foo
 }
 else
 {
   result = (long)foo[0];   // Access with mov.d
 }

But I am unable to get the compiler to change anything based on the compiler switch.  I assume I am missing something obvious and someone can point it out while I still have some hair left.

Ta.
Logged
flo0319
Junior Member
**
Offline Offline

Posts: 82

Thank You
-Given: 7
-Receive: 16


« Reply #1 on: August 21, 2015, 08:22:00 20:22 »

Can you put here the output of your build ?

if you are using the MPLAB X IDE you should add the -merrata=psv_trap in project properties - C30 global option - additional option field, if you are using your one makefile just add it to your flags(options) list

If you already have verified that, check the compiler version
Logged
Tupperware
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 13
-Receive: 24


« Reply #2 on: August 21, 2015, 09:54:33 21:54 »

Compiler is C30 v3.12 (I know there are later versions, but this is the one I have to use)

Compiler options set in Build options->alternate settings. I am compiling with and without the psv_trap bit.

Code:
-g -Wall -O1 -c -save-temps -merrata=psv_trap

The build output window shows the option is correctly applied:

Code:
Make: The target "C:\Work\POWER_TILE\SourceToObject\SSPM - Without Compiler Options\PSV_Test.o" is out of date.
Executing: "C:\Program Files\Microchip\MPLAB C30\bin\pic30-gcc.exe" -mcpu=33FJ128GP206 -x c -c   "source\PSV_Test.c" -o"PSV_Test.o" -g -Wall -O1 -c -save-temps -merrata=psv_trap

The assembler output is shown below.  I don't get mov.d or a mov[--w0] or similar so I think the issue is my C code construction Sad.

Code:
int PSV_Test_Workaround(int x)
{
 int result = 0;   
 CORCONbits.PSV = 1;                 // ensure that PSV is enabled
   0: 00 40 a8    bset.b    0x0, #0x2
 PSVPAG = __builtin_psvpage(&foo);   // set the PSVPAG correctly
   2: 01 00 20    mov.w     #0x0, w1
   4: 80 00 fd    exch      w0, w1
   6: 00 e0 b7    mov.b     WREG, 0x0
   8: 80 00 fd    exch      w0, w1
                                     // for accessing foo
 if (foo[--x] == 9)           // Access with pre-decrement
   a: 00 00 40    add.w     w0, w0, w0
   c: 00 80 e9    dec2.w    w0, w0
   e: 01 00 20    mov.w     #0x0, w1
  10: 60 80 78    mov.w     [w0+w1], w0
  12: e9 0f 50    sub.w     w0, #0x9, [w15]
  14: 00 00 3a    bra       NZ, 0x16
 {
   result = bar;                     // we know bar is in the same
  16: 00 00 80    mov.w     0x0, w0
  18: 00 00 37    bra       0x1a <.L2>

0000001a <.L2>:
                                     // PSV page as foo
 }
 else
 {
   result = (long)foo[0];   // Access with mov.d
  1a: 00 00 80    mov.w     0x0, w0

0000001c <.L4>:
 }
 return(result);   
} /* end PSV_Test_Workaround */
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC