1

I'm new to C and to microcontrollers and i'm trying to learn by reproducing projects I find on the net. Here I have a project created on the same hardware than I have (PIC32MX534F064H), and i'm basically translating the syntax from mikroC to the microchip compiler i'm using (XC32 v1.34). I'm using MPLab IDE X for this.

On this project, I'm trying to define a large (32000) vector of unsigned integers and the compiler throws an error on me, that I interpret as if the vector was too large for the device. Which isn't the case since that project worked on the same hardware, but in mikroC.

I tried lower the vector size, a 3200 sized vector compiles perfectly, so i think it's about the size of this vector and not syntax.

I googled for hours and looked in the datasheet and found that for smaller pics, there was a specific way to design large arrays, but there is no documentation about this for PIC32.

So when i define my vector like this

#include <p32xxxx.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>       
#include <xc.h> 
#include <plib.h> 

signed int data[32000];

The compilator throws this at me

nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' 
failed /Applications/microchip/xc32/v1.34/bin/bin/gcc/pic32mx/4.5.2/../../../..
/bin/xc32-ld: dist/default/production/LED.X.production.elf section 
`.bss' will not fit in region `kseg1_data_mem'
/Applications/microchip/xc32/v1.34/bin/bin/gcc/pic32mx/4.5.2/../../../..
/bin/xc32-ld: Link terminated due to previous error(s).

right now, i'm clueless about what I should try next so .. any help is appreciated.

EDIT

My information were wrong indeed, the harware was updated to handle such a vector and I wasn't aware of it. thanks for your answer

Add
  • 11
  • 2

1 Answers1

3

From the device overview it is apparent that the MCU in question is 32-bit ("80MHz/105DMIPS, 32-bit MIPS M4K Core"), hence signed int is 32 bits wide too. The program memory is limited to 64 KiB ("64K RAM (can execute from RAM)"), yet you're trying to allocate an array of 32000 * 4 bytes.

How about short for array element?


Notice that you'd probably want to ensure that the program doesn't get loaded to RAM too if it is executable from the flash, otherwise there isn't too much space left.

  • THanks for your comments, indeed it was my fault, i was certain that someone else succeeded in using such a large array in that harware, but that was not the case, the hardware had been upgraded in between – Add May 11 '19 at 15:34