Dear Mr/Mrs,
I am debugging my code and I see that a simple operation is not done correctly:
eTPU->MCR.SCMSIZE = 9 and code size = 20480 so the result must be 0 and I see instead -$00004800
----------------------------------------------------------------------------------------------------------------------
uint32_t fs_etpu_init(struct etpu_config_t p_etpu_config, uint32_t *code,
uint32_t code_size, uint32_t *globals, uint32_t globals_size)
{
uint32_t *code_end;
int32_t unused_code_ram;
int8_t x;
unused_code_ram = ((eTPU->MCR.B.SCMSIZE + 1 ) * 2048) - code_size;
if ( unused_code_ram < 0 ) return((uint32_t)FS_ETPU_ERROR_CODESIZE);
/* 1. Load microcode */
/* In order for the MISC function to work with code that is small than
the code memory any unused locations must be set to zero. */
/* enable writting to SCM */
eTPU->ECR_A.B.MDIS = 1; /* stop eTPU_A */
eTPU->ECR_B.B.MDIS = 1; /* stop eTPU_B */
eTPU->MCR.B.VIS = 1; /* enable CPU writes to eTPU code memory */
----------------------------------------------------------------------------------------------------------------------
i have checked that eTPU->MCR.B.SCMSIZE is "0" but when I see the debugger screen tells that it is '9'. How can this be possible if the header is ok?. Any idea?.