Any problem in declaring and using VARs longer than 512 bytes?
Hello People,
I am starting a project (a portable medical datalogger) and have made some tries to determine what is better for doing this, PICBASIC or C18. In the process of acquiring the data from the amplifiers of the equipment (28 channels, 16 bit/sample, 128 sample/sec/channel) and posterior sending to a SD card I can not reach enough loading speed to the SD if I do not use two buffers of 512 bytes and flush them (one in the main body of the program while the other is being filled in a ISR basis). I started with PICBASIC PRO but early discovered that an erratic or unspected behaviour appear when I tried to address the 512 byte long arrays. So I split them in two 256 byte long sub-arrays and it worked. No need to say that this has made the code complicated and obscure. Is there some issue in PICBASIC PRO with the definitions of vars longer than a segment of 256 bytes? In C18 I had to redefine some bank boundaries to inform the linker that I had variables that jump from one bank to another. I feel more confortable programming in PICBASIC PRO because it isolates me from having to deal with delays, serial channels in non-hardware dedicated pins, etc, but the ¿poor? managing of big variables in PBP can stop me using it this time. The PIC is 18F4620 at 20Mhz, the ADc is a 7813 through SPI, the SD is loaded through a dedicated interface programmed in a chip (DosOnChip).
Has anybody used VARs longer than 256 bytes, for example:
BF1 VAR BYTE[512]
i VAR word
data VAR BYTE
//and then
data = BF1[i]
Thanks
In PBP arrays cannot span across banks
Hi,
Since one bank of data RAM can hold 256 bytes only you cannot span arrays across banks. So splitting it up is the only way perhaps. Using C18 has its own benefits of a better memory management than PBP for both global and local variables. Also it uses a software stack that depends on the free RAM you have and can be always bigger than the hardware stack. You can always create a subroutine for your data access that automatically chooses the specific bank depending on your array index and dumps it to a temporary variable. This should not complicate things much.
Sorry I missed the 18Fxxx issue
Hi All,
Sorry I missed that the used chip is a PIC18. It does have a linear addressing for the RAM location.
Quote:
Arrays must fit entirely within one RAM bank on most PICmicro MCUs.
They may not span RAM banks on 12-bit, 14-bit or 17Cxxx devices.
(Arrays may span banks on 18Xxxx devices. Byte- and word-sized
arrays are only limited in length by the amount of memory.) The
compiler will assure that arrays will fit in memory before successfully
compiling.
Define your array to a specific bank such that it spills over to the next bank.