Exception on reconfigure_port Topic is solved

If you have a simple question and just want an answer.
User avatar
Caleb
Experienced Member
Posts: 82
Joined: Thu Apr 04, 2013 10:14 pm

Exception on reconfigure_port

Post by Caleb »

I believe I copied code precisely from AN10060...using 14.0.3:

out port p = XS1_PORT_1A;

 
out port * movable pp = &p;
buffered out port:32 * movable buffered_p;
buffered_p = reconfigure_port(move(pp), buffered out port:32);
 
running this gives this result:
xrun: Program received signal ET_ECALL, ../src/extensions/flash.xc:75:1: error: movable pointer `buffered_p' does not point to its initial object when going out of scope
      buffered out port:32 * movable buffered_p;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      .
      [Switching to tile[0] core[2]]
      0x00010572 in flash_read_preset () at ../src/extensions/flash.xc:76
      76 buffered_p = reconfigure_port(move(pp), buffered out port:32);
 

What am I missing? 

The Application Note AN10060 specified tools version 14.0.0. The function reconfigure_port() is available in 13.2,2.  I get an exception running this code with 13.2.2, Should it be possible to use reconfigure_port with 13.2.2? The current USB audio reference SW project generates an error when compiling with 14 tools...not sure which tools to use in order to reconfigure a port in a USB audio application.

thanks

View Solution
User avatar
myndideal
Active Member
Posts: 59
Joined: Thu May 05, 2011 10:00 pm
Location: Budapest

Post by myndideal »

Hi, Your movable ptr is local in a function. When function returns, stack will be freed, and small synthetized code (destructor) will be called for movable ptrs. This generates the ET_ECALL exception. Simple workaround is to move your local "buffered out port:32 * movable buffered_p;" declaration to global scope. If a movable ptr is not null, it is the owner of the pointer, destruction is not possible. So the reconfigure_port() function do its job well, it is set a movable ptr to a not-null value. Before you left the function scope, the best to remove the contents of the movable ptr by another move() call.  If you want to return with this ptr, in example: return move(buffered_p); Theoretically it is because the pointer owner must be in one and only one scope.