v3.0.0-a36 : Brought over the new command code defines (rather than bit flags) and FIFO element structure updates from CM branch. Compiles, runs simple tests fine.

feature/ISR_AssemblyRewrite
EmbeddedMan 2024-01-20 15:07:21 -06:00
rodzic 1b66fbf89f
commit 61d3179252
13 zmienionych plików z 21225 dodań i 20567 usunięć

Wyświetl plik

@ -50,6 +50,7 @@
<itemPath>source/ebb_demo.c</itemPath>
<itemPath>source/isr_helpers.asm</itemPath>
<itemPath>source/ebb_print.c</itemPath>
<itemPath>source/squareroot.s</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
@ -68,7 +69,7 @@
<targetDevice>PIC18F46J50</targetDevice>
<targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard>
<platformTool>noID</platformTool>
<platformTool>PICkit3PlatformTool</platformTool>
<languageToolchain>C18</languageToolchain>
<languageToolchainVersion>3.47</languageToolchainVersion>
<platform>3</platform>
@ -112,8 +113,8 @@
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
<makeUseCleanTarget>false</makeUseCleanTarget>
<makeCustomizationPreStep></makeCustomizationPreStep>
<makeCustomizationPostStepEnabled>true</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep>"C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mplink.exe" "source\BL_rm18f46j50_g.lkr" -p18f46j50 -m"dist/EBBv13_with_bootloader/production/EBF.X.production.map" -i -l"./source" -z__MPLAB_BUILD=1 -u_CRUNTIME -l "C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin"\\..\\lib -o dist/EBBv13_with_bootloader/production/app.X.production.cof build/EBBv13_with_bootloader/production/_ext/343710134/usb_device.o build/EBBv13_with_bootloader/production/_ext/131024517/usb_function_cdc.o build/EBBv13_with_bootloader/production/source/ebb.o build/EBBv13_with_bootloader/production/source/main.o build/EBBv13_with_bootloader/production/source/RCServo2.o build/EBBv13_with_bootloader/production/source/UBW.o build/EBBv13_with_bootloader/production/source/usb_descriptors.o build/EBBv13_with_bootloader/production/source/ebb_print.o</makeCustomizationPostStep>
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep></makeCustomizationPostStep>
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
@ -159,7 +160,7 @@
<property key="extra-lib-directories" value="./source"/>
<property key="hex-output-format" value="INHX32"/>
<property key="map-file" value="&quot;${DISTDIR}/EBF.X.${IMAGE_TYPE}.map&quot;"/>
<appendMe value="-p18f46j50"/>
<appendMe value="-i -p18f46j50"/>
</C18-LD>
<C18LanguageToolchain>
<property key="extended-mode" value="false"/>
@ -170,6 +171,100 @@
<property key="stack-analysis-mcc18" value="false"/>
<property key="stack-analysis-mplink" value="false"/>
</C18LanguageToolchain>
<PICkit3PlatformTool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="FullChipProgramming"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="debugoptions.debug-startup" value="Use system settings"/>
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="event.recorder.enabled" value="false"/>
<property key="event.recorder.scvd.files" value=""/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="lastid" value=""/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="true"/>
<property key="memories.configurationmemory" value="true"/>
<property key="memories.configurationmemory2" value="true"/>
<property key="memories.dataflash" value="true"/>
<property key="memories.eeprom" value="true"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="true"/>
<property key="memories.instruction.ram" value="true"/>
<property key="memories.instruction.ram.ranges"
value="${memories.instruction.ram.ranges}"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.ranges" value="0-fff7"/>
<property key="poweroptions.powerenable" value="false"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preservedataflash" value="false"/>
<property key="programoptions.preservedataflash.ranges"
value="${programoptions.preservedataflash.ranges}"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveeeprom.ranges" value=""/>
<property key="programoptions.preserveprogram.ranges" value=""/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.programcalmem" value="false"/>
<property key="programoptions.programuserotp" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</PICkit3PlatformTool>
<Tool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="FullChipProgramming"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="debugoptions.debug-startup" value="Use system settings"/>
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="event.recorder.enabled" value="false"/>
<property key="event.recorder.scvd.files" value=""/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="lastid" value=""/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="true"/>
<property key="memories.configurationmemory" value="true"/>
<property key="memories.configurationmemory2" value="true"/>
<property key="memories.dataflash" value="true"/>
<property key="memories.eeprom" value="true"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="true"/>
<property key="memories.instruction.ram" value="true"/>
<property key="memories.instruction.ram.ranges"
value="${memories.instruction.ram.ranges}"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.ranges" value="0-fff7"/>
<property key="poweroptions.powerenable" value="false"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preservedataflash" value="false"/>
<property key="programoptions.preservedataflash.ranges"
value="${programoptions.preservedataflash.ranges}"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveeeprom.ranges" value=""/>
<property key="programoptions.preserveprogram.ranges" value=""/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.programcalmem" value="false"/>
<property key="programoptions.programuserotp" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</Tool>
<item path="source/ebb_demo.c" ex="true" overriding="false">
<C18>
</C18>

Wyświetl plik

@ -4,7 +4,7 @@
<defaultConf>0</defaultConf>
<confs>
<conf name="EBBv13_with_bootloader" type="2">
<platformToolSN>noToolString</platformToolSN>
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>900A:=&lt;rev>0002:=&lt;man>Microchip Technology Inc.:=&lt;prod>PICkit 3:=&lt;sn>BUR101260159:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<languageToolchainDir>C:\MCC18\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>

Wyświetl plik

@ -35,11 +35,14 @@
<word>Bitfield</word>
<word>bootup</word>
<word>breifly</word>
<word>codebase</word>
<word>comamnds</word>
<word>Fosc</word>
<word>init</word>
<word>microstep</word>
<word>paramters</word>
<word>Prescale</word>
<word>refactor</word>
<word>struct</word>
</spellchecker-wordlist>
</configuration>

Wyświetl plik

@ -58,14 +58,14 @@ LIBPATH .
#FI
#IFDEF _DEBUGCODESTART
CODEPAGE NAME=bootloader START=0x0 END=0xFFF PROTECTED
CODEPAGE NAME=vectors START=0x1000 END=0x1029 PROTECTED
#IFDEF _DEBUGCODESTART
CODEPAGE NAME=page START=0x102A END=_CODEEND
CODEPAGE NAME=debug START=_DEBUGCODESTART END=_CEND PROTECTED
CODEPAGE NAME=save START=0xF800 END=0xFFF7 PROTECTED
#ELSE
CODEPAGE NAME=bootloader START=0x0 END=0xFFF PROTECTED
CODEPAGE NAME=vectors START=0x1000 END=0x1029 PROTECTED
// Top of program memory is decreased by two flash blocks - one to hold the
// configuration words (we don't want them to ever get erased) and one to hold
// our persistent storage across reboots (like the EBB's name)
@ -96,7 +96,7 @@ DATABANK NAME=FIFO_scn START=0x600 END=0xDFF
DATABANK NAME=stacks START=0xE00 END=0xEBF
#IFDEF _DEBUGDATASTART
DATABANK NAME=gpr14 START=0xE00 END=_DATAEND
DATABANK NAME=gpr13 START=0xD00 END=_DATAEND
DATABANK NAME=dbgspr START=_DEBUGDATASTART END=_DEND PROTECTED
#ELSE //no debug
// DATABANK NAME=gpr14 START=0xE00 END=0xEBF

Wyświetl plik

@ -388,21 +388,21 @@ UINT8 RCServo2_Move(
if (!bittst(TestMode, TEST_MODE_DEBUG_BLOCK_FIFO_NUM))
{
// Now copy the values over into the FIFO element
FIFOPtr[gFIFOIn].Command = COMMAND_SERVO_MOVE_BIT;
FIFOPtr[gFIFOIn].DelayCounter = HIGH_ISR_TICKS_PER_MS * (UINT32)Delay;
FIFOPtr[gFIFOIn].ServoChannel = Channel;
FIFOPtr[gFIFOIn].ServoRPn = RPn;
FIFOPtr[gFIFOIn].ServoPosition = Position;
FIFOPtr[gFIFOIn].ServoRate = Rate;
FIFOPtr[gFIFOIn].Command = COMMAND_SERVO_MOVE;
FIFOPtr[gFIFOIn].m.sm.DelayCounter = HIGH_ISR_TICKS_PER_MS * (UINT32)Delay;
FIFOPtr[gFIFOIn].m.sm.ServoChannel = Channel;
FIFOPtr[gFIFOIn].m.sm.ServoRPn = RPn;
FIFOPtr[gFIFOIn].m.sm.ServoPosition = Position;
FIFOPtr[gFIFOIn].m.sm.ServoRate = Rate;
// Check that DelayCounter doesn't have a crazy high value (this was
// being done in the ISR, now moved here for speed)
if (FIFOPtr[gFIFOIn].DelayCounter > HIGH_ISR_TICKS_PER_MS * (UINT32)0x10000)
if (FIFOPtr[gFIFOIn].m.sm.DelayCounter > HIGH_ISR_TICKS_PER_MS * (UINT32)0x10000)
{
// Ideally we would throw an error to the user here, but since we're in
// the helper function that's not so easy. So we just set the delay time
// to zero and hope they notice that their delays aren't doing anything.
FIFOPtr[gFIFOIn].DelayCounter = 0;
FIFOPtr[gFIFOIn].m.sm.DelayCounter = 0;
}
gFIFOIn++;

Wyświetl plik

@ -151,7 +151,7 @@ volatile UINT16 g_StepperDisableTimeoutS; // Seconds of no motion before m
volatile UINT16 g_StepperDisableSecondCounter; // Counts milliseconds up to 1 s for stepper disable timeout
volatile UINT16 g_StepperDisableCountdownS; // After motion is done, counts down in seconds from g_StepperDisableTimeoutS to zero
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.0-a35"};
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.0-a36"};
#pragma udata ISR_buf = 0x100
volatile unsigned int ISR_A_FIFO[16]; // Stores the most recent analog conversions

Wyświetl plik

@ -103,29 +103,19 @@ typedef enum
PEN_UP
} PenStateType;
// Bitfield defines the CommandType BYTE in the MoveCommandType
// We use bits now in this byte in order to trigger a command,
// one bit per command. Thus we can only have 8 total commands that are passed
// through the FIFO to the ISR. Note that three USB commands (SM, XM HM) are
// all the same and represented by one bit.
// Only one bit must be set at a time or undefined behavior will occur.
// If no bits are set, then the command is effectively COMMAND_NONE.
#define COMMAND_DELAY_BIT_NUM 0u
#define COMMAND_SERVO_MOVE_BIT_NUM 1u
#define COMMAND_SE_BIT_NUM 2u
#define COMMAND_EM_BIT_NUM 3u
#define COMMAND_SM_XM_HM_MOVE_BIT_NUM 4u
#define COMMAND_LM_MOVE_BIT_NUM 5u
#define COMMAND_LT_MOVE_BIT_NUM 6u
#define COMMAND_NONE_BIT 0u
#define COMMAND_DELAY_BIT 1u
#define COMMAND_SERVO_MOVE_BIT (1u << COMMAND_SERVO_MOVE_BIT_NUM)
#define COMMAND_SE_BIT (1u << COMMAND_SE_BIT_NUM)
#define COMMAND_EM_BIT (1u << COMMAND_EM_BIT_NUM)
#define COMMAND_SM_XM_HM_MOVE_BIT (1u << COMMAND_SM_XM_HM_MOVE_BIT_NUM)
#define COMMAND_LM_MOVE_BIT (1u << COMMAND_LM_MOVE_BIT_NUM)
#define COMMAND_LT_MOVE_BIT (1u << COMMAND_LT_MOVE_BIT_NUM)
// Defines for the CommandType BYTE in the MoveCommandType
// Note that three USB commands (SM, XM HM) are
// all the same and represented by one command value.
#define COMMAND_NONE 0u
#define COMMAND_DELAY 1u
#define COMMAND_SERVO_MOVE 2u
#define COMMAND_SE 3u
#define COMMAND_EM 4u
#define COMMAND_SM_XM_HM_MOVE 5u
#define COMMAND_LM_MOVE 6u
#define COMMAND_LT_MOVE 7u
#define COMMAND_CM_OUTER_MOVE 8u
#define COMMAND_CM_INNER_MOVE 9u
typedef enum
{
@ -137,12 +127,13 @@ typedef enum
// Byte union used for accumulator (unsigned))
typedef union union32b4 {
struct byte_map {
UINT8 b1; // Low byte
UINT8 b1; // Low bytegTmpIntervals =
UINT8 b2;
UINT8 b3;
UINT8 b4; // High byte
} bytes;
UINT32 value;
UINT32 circle_accum;
} u32b4_t;
// Byte union used for rate (signed)
@ -160,8 +151,11 @@ typedef union union32b4 {
// are sent from the command parser to the ISR move engine.
// Currently 47 bytes long
typedef struct
{ // Used in which commands? (SM = SM/XM/HM, DL = Delay, S2 = any servo move)
{
UINT8 Command; // SM DL S2 SE EM LM LT
union {
struct {
// Used in which commands? (SM = SM/XM/HM, DL = Delay, S2 = any servo move)
UINT8 DirBits; // SM EM LM LT
UINT32 DelayCounter; // SM DL S2 SE LM LT NOT Milliseconds! In 25KHz units
UINT8 SEState; // SM SE LM LT
@ -174,8 +168,27 @@ typedef struct
UINT8 ServoChannel; // S2
UINT16 ServoRate; // S2
UINT16 SEPower; // SE
} sm;
struct { // Currently 39 bytes long
UINT8 DirBits;
s32b4_t Rate[NUMBER_OF_STEPPERS];
UINT32 Steps[NUMBER_OF_STEPPERS];
UINT16 VScaleK;
UINT8 m_alpha;
INT8 bits_left;
INT16 x_f;
INT16 y_f;
INT32 x_t;
INT32 y_t;
UINT8 direction;
INT16 x_pos_last;
INT16 y_pos_last;
UINT8 typ_seg;
} cm;
} m;
} MoveCommandType;
// Define global things that depend on the board type
// STEP2 = RD4
#define STEP2_BIT_NUM 4u