v3.0.0-a23 : Updated linker script RAM map and moved some variables around for simpler allocation. Bumped max FIFO size back up to 32 elements. Still have 226 unallocated bytes of RAM.

feature/48bitSnap
EmbeddedMan 2023-10-05 14:22:52 -05:00
rodzic 86cf690d7c
commit 4430da25c2
8 zmienionych plików z 20823 dodań i 20776 usunięć

Wyświetl plik

@ -1,15 +1,15 @@
// Ram Usage for EBB v3.0.0-a23
// currently 226 bytes unallocated
//
//Name Start End Purpose
//accessram 0x000 0x05F
// 0x000 0x022 small ISR variables
// 0x023 0x03F compiler temp
// 0x043 0x05F [unused (33d)]
// 0x000 0x022 small ISR variables (ebb.c)
// 0x023 0x053 compiler temp
//gpr0 0x060 0x0FF
// 0x060 0x0F9 RCServo2 variables, UBW.c
// 0x060 0x0F9 RCServo2.c, UBW.c
//gpr1 0x100 0x1FF
// 0x100 0x17F UBW.c, compiler startup variables
// 0x180 0x1FF Rest of ISR variables
// 0x100 0x178 UBW.c (A and D FIFOs), ebb.c
// 0x180 0x1FF Rest of ISR variables, ebb.c, ebb_print.c, UBW.c
//gpr2 0x200 0x2FF
// 0x200 0x27F TX and RX command buffers
// 0x280 0x2FF USB Descriptors
@ -17,21 +17,22 @@
// 0x300 0x3FF RX buffer
//gpr4 0x400 0x4FF
// 0x400 0x438 USB Buffer Description Tables (USB SIE hardware SFRs), usb_device.c variables
// 0x439 0x4FF UBW.c misc variables, compiler startup variables
// 0x439 0x4FF [unused (198d)]
//gpr5 0x500 0x5FF
// 0x500 0x5F5 usb_function_cdc.c variables, UBW.c misc variables
//gpr6 0x600 0x6FF CommandFIFO
//gpr7 0x700 0x7FF CommandFIFO
//gpr8 0x800 0x8FF CommandFIFO
//gpr9 0x900 0x9FF CommandFIFO
//gpr10 0xA00 0xAFF CommandFIFO
//gpr11 0xB00 0xBFF CommandFIFO
//gpr12 0xC00 0xCFF CommandFIFO
//gpr13 0xD00 0xDFF CommandFIFO (spare/extra space)
//gpr14 0xE00 0xEBF Stack (note, not full 256 bytes anymore, only 192 now)
//sfr14 0xEC0 0xEFF SFRs
//sfr15 0xF00 0xF5F SFRs
//accesssfr 0xF60 0xFFF SFRs
// 0x500 0x5E3 usb_function_cdc.c, compiler startup
// 0x5E4 0x5FF [unused (28d)]
//gpr6 0x600 0x6FF CommandFIFO
//gpr7 0x700 0x7FF CommandFIFO
//gpr8 0x800 0x8FF CommandFIFO
//gpr9 0x900 0x9FF CommandFIFO
//gpr10 0xA00 0xAFF CommandFIFO
//gpr11 0xB00 0xBFF CommandFIFO
//gpr12 0xC00 0xCFF CommandFIFO
//gpr13 0xD00 0xDFF CommandFIFO
//gpr14 0xE00 0xEBF Stack (note, not full 256 bytes anymore, only 192 now)
//sfr14 0xEC0 0xEFF SFRs
//sfr15 0xF00 0xF5F SFRs
//accesssfr 0xF60 0xFFF SFRs
// File: 18f46j50_g.lkr
// Generic linker script for the PIC18F46J50 processor
@ -82,7 +83,7 @@ DATABANK NAME=gpr2 START=0x200 END=0x2FF
DATABANK NAME=gpr3 START=0x300 END=0x3FF
DATABANK NAME=gpr4 START=0x400 END=0x4FF
DATABANK NAME=gpr5 START=0x500 END=0x5FF
// Command FIFO takes over all banks from 0x600 to 0xDFF
// Command FIFO takes over all banks from 0x600 to 0xDFF (length of 0x800 or 2048d)
//DATABANK NAME=gpr6 START=0x600 END=0x6FF
//DATABANK NAME=gpr7 START=0x700 END=0x7FF
//DATABANK NAME=gpr8 START=0x800 END=0x8FF
@ -90,9 +91,9 @@ DATABANK NAME=gpr5 START=0x500 END=0x5FF
//DATABANK NAME=gpr10 START=0xA00 END=0xAFF
//DATABANK NAME=gpr11 START=0xB00 END=0xBFF
//DATABANK NAME=gpr12 START=0xC00 END=0xCFF
DATABANK NAME=FIFO_scn START=0x600 END=0xCFF
//DATABANK NAME=gpr13 START=0xD00 END=0xDFF
DATABANK NAME=stacks START=0xD00 END=0xEBF
DATABANK NAME=FIFO_scn START=0x600 END=0xDFF
DATABANK NAME=stacks START=0xE00 END=0xEBF
#IFDEF _DEBUGDATASTART
DATABANK NAME=gpr14 START=0xE00 END=_DATAEND
@ -113,6 +114,6 @@ ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
#IFDEF _DEBUGDATASTART
STACK SIZE=0x100 RAM=gpr13
#ELSE
STACK SIZE=0x1C0 RAM=stacks
STACK SIZE=0x0C0 RAM=stacks
#FI
#FI

Wyświetl plik

@ -309,15 +309,21 @@ typedef enum
SOLENOID_PWM
} SolenoidStateType;
// This is the FIFO that stores the motion commands. It spans multiple RAM
// banks from 0x800 through 0xCFF, and must only be accessed via pointer
#pragma udata FIFO_scn
MoveCommandType CommandFIFO[COMMAND_FIFO_MAX_LENGTH];
// These global variables are deliberately put into "Bank" 1 of RAM.
// They are every global variable that the 25KHz ISR has to access.
// With them all being in bank 1, no bank switch instructions are needed
// in the ISR save for one at the very top.
// This is the FIFO that stores the motion commands. It spans multiple RAM
// banks from 0x600 through 0xDFF (length 0x800 or 2048d), and must only be
// accessed via pointer.
// Note that no matter what COMMAND_FIFO_MAX_LENGTH is set to, we reserve the
// entire 0x800 bytes of space in the FIFO_scn here. That prevents the linker
// from putting variables after this section.
#pragma udata FIFO_scn
UINT8 CommandFIFO[COMMAND_FIFO_SIZE_BYTES];
// These global variables are deliberately put into "Bank" 0 of RAM (the
// access/near bank).
// They are the small global variables that the 25KHz ISR has to access.
// With them all being in bank 0, no bank switch instructions are needed
// to access them.
#pragma udata access ISR_access
//static UINT8 TookStep; // LSb set if a step was taken
@ -376,28 +382,28 @@ UINT8 near FIFO_out_ptr_low;
volatile static near INT32 globalStepCounter1;
volatile static near INT32 globalStepCounter2;
#pragma udata ISR_globals = 0x180
MoveCommandType CurrentCommand;
// Pointer to a MoveCommandType element of the FIFO array
MoveCommandType * FIFOPtr = &CommandFIFO[0];
// Accumulator for each axis
static u32b4_t acc_union[2];
near MoveCommandType * FIFOPtr = (near MoveCommandType *)&CommandFIFO[0];
// Accumulator for each axis
static near u32b4_t acc_union[2];
// ISR globals used in test modes for keeping track of each move
static UINT32 gISRTickCountForThisCommand;
static UINT32 gISRStepCountForThisCommand;
static INT32 gISRPositionForThisCommand;
static near UINT32 gISRTickCountForThisCommand;
static near UINT32 gISRStepCountForThisCommand;
static near INT32 gISRPositionForThisCommand;
// These globals are now set to be put anywhere the linker can find space for them
#pragma udata
static MoveCommandType gMoveTemp; // Commands fill this then copy to FIFO
// Bank 1 is the "ISR Bank". By placing all variables that the ISR needs
// access to either in the access bank (above) or in Bank 1, then the bank
// select register can be kept pointing to Bank 1 and no bank switch instructions
// are needed in the iSR.
#pragma udata ISR_globals = 0x180
// The move command containing the currently executing move command in the ISR
MoveCommandType CurrentCommand;
unsigned int DemoModeActive;
unsigned int comd_counter;
static SolenoidStateType SolenoidState;
static unsigned int SolenoidDelay;
@ -405,7 +411,6 @@ static unsigned int SolenoidDelay;
static PenStateType PenState;
static unsigned long NodeCount;
static UINT8 gSL_Storage[32];
unsigned char QC_ms_timer;
static UINT StoredEngraverPower;
// Set TRUE to enable solenoid output for pen up/down
@ -437,6 +442,16 @@ static INT32 gTmpJerk1;
static INT32 gTmpJerk2;
static UINT32 gTmpClearAccs;
// These globals are now set to be put anywhere the linker can find space for them
#pragma udata
static MoveCommandType gMoveTemp; // Commands fill this then copy to FIFO
// Storage for the 32 bytes of "SL" command values
static UINT8 gSL_Storage[32];
// Local function definitions

Wyświetl plik

@ -87,7 +87,12 @@
// we artifically set this to 32 elements. That gives us room to grow the size
// of the command structure without needing to decrease the maximum size
// of the FIFO in elements.
#define COMMAND_FIFO_MAX_LENGTH 28u
#define COMMAND_FIFO_MAX_LENGTH 32u
// The total number of bytes of space we want the FIFO to be (i.e. reserve
// maximum 2048 bytes, even if we're not using all of it)
#define COMMAND_FIFO_SIZE_BYTES 0x800
typedef enum
{
@ -292,7 +297,7 @@ typedef struct
extern MoveCommandType * FIFOPtr;
extern near MoveCommandType * FIFOPtr;
extern near volatile UINT8 gFIFOLength;
extern near volatile UINT8 gFIFOIn;
extern near volatile UINT8 gFIFOOut;