P2 Cog Startup Routine v0.11 for PASM programs
Cluso99
Posts: 18,069
P2 Cog Startup Routine v0.11 for PASM programs
* Added option to suppress the "Auto Detect" message display
* Added option to load code into LUT
* Added option to execute user HUBEXEC code before returning to the users COG program
P2 Cog Startup Routine v0.10 for PASM programs
Here is a simple little utility routine that you can call from your user pasm program to setup to use the P2 ROM Serial/Monitor...
Only takes 1 long at the start of your program to call the routine that resides in hub using hubexec, and you can still use it for your own variable too.
Note: It does not save your clock values to the hub ram. Maybe later. Requires fastspin.
Enjoy
* Added option to suppress the "Auto Detect" message display
* Added option to load code into LUT
* Added option to execute user HUBEXEC code before returning to the users COG program
P2 Cog Startup Routine v0.10 for PASM programs
Here is a simple little utility routine that you can call from your user pasm program to setup to use the P2 ROM Serial/Monitor...
Only takes 1 long at the start of your program to call the routine that resides in hub using hubexec, and you can still use it for your own variable too.
'' +---------------------------------------------------------------------------+ '' | Cluso's P2 COG startup routine with ROM Serial/Monitor v0.11 | '' +---------------------------------------------------------------------------+ '' | Authors: (c)2019-2020 "Cluso99" (Ray Rodrick) | '' | Modifications: | '' | License: MIT License | '' +---------------------------------------------------------------------------+ '' + This routine resides in HUB and is called immediately you run your + '' + first COG. + '' + Since it resides in HUB it only takes 1 long in your COG space. + '' + This routine will... + '' + * Calculate your clock constants in a CON section + '' + * Define the ROM Serial/Monitor entry points in a CON section + '' + * Determine if a P2EVAL or P2D2 (requires pulldown on "pincfg" = 25) + '' + * From your "begin call ##\_hubStartup" as the first COG instruction...+ '' + * Sets the P2 clock frequency + '' + * Initialises the ROM Serial/Monitor for use in your program + '' + * Delays config time to allow you to start a Terminal prog on your PC + '' + * Determines if you're running on a P2EVAL or P2D2 and displays a string + '' + * If _DISPLAY_AUTO_STR <> 0 then an "Auto Detected..." will be displayed + '' + * Displays your "str_progid" string ($0 will prevent the display) + '' + * If _LOAD_LUT_CODE <> 0 then LUT will be loaded from... + '' + * _USER_LUT_BEGIN to _USER_LUT_END + '' + * If _RUN_HUBEXEC <> 0 then a JMP to the users hubexec code starting at + '' + _USER_HUBEXEC_BEGIN + '' + * Returns to your COG program + '' + Include the following sections at the appropriate place in your code... + '' +---------------------------------------------------------------------------+ '' RR20200604 v010 first release '' RR20200605 v011 add option: suppress display, load LUT, and run HUBEXECAnd the demo program that uses it...
CON '+-------[ Select startup options ]--------------------------------------------+ _CLOCKFREQ = 200_000_000 ' clock frequency _clkfreq = _CLOCKFREQ ' _BAUD = 115_200 ' serial speed _STARTUP_DELAY = _CLOCKFREQ * 2 ' 2s delay to get terminal running _DISPLAY_AUTO_STR = 1 ' $0 to suppress display "Auto Detected..." _LOAD_LUT_CODE = 0 ' $0 to suppress loading LUT code _RUN_HUBEXEC = 1 ' $0 to suppress running HUBEXEC code '+-----------------------------------------------------------------------------+ DAT '+============[ COG startup code ]=============================================+ org 0 ' compile for cog workarea '\ used as a temp variable by hubexec code begin call #\_hubCogStart '/ set clock,detect pcb,start-serial,output program-id '+-----------------------------------------------------------------------------+ .here call #\_hubMonitor '\ <<<<<<<<<<<<<<<<<< your cog code goes here jmp #.here '/ <<<<<<<<<<<<<<<<<< your cog code goes here '+=============================================================================+ # INCLUDE "COG_STARTUP.spin2" DAT ''============[ HUB VARIABLES ]================================================+ orgh str_progid byte " Cluso's COG_STARTUP demo",13,10,0 ' change to suit str_progid2 byte " Another message from hubexec",13,10,0 alignl '+=============================================================================+ _USER_HUBEXEC_BEGIN ' users hubexec code begins here mov lmm_p, ##str_progid2 '\ <<<<<<<<<<<<<<<<<< your hubexec code goes here call #\_hubTxStr '/ <<<<<<<<<<<<<<<<<< your hubexec code goes here RET ' return to users cog code '+=============================================================================+ _USER_LUT_BEGIN ' users lut code to be loaded begins here ' ..... '\ <<<<<<<<<<<<<<<<<< your lut code goes here ' ..... '/ <<<<<<<<<<<<<<<<<< your lut code goes here _USER_LUT_END ' users lut code to be loaded ends here '+=============================================================================+
Note: It does not save your clock values to the hub ram. Maybe later. Requires fastspin.
Enjoy
Comments
I think that I'll extend it to allow additional hubexec code to be executed when placed there by the user, and to permit loading LUT as well. I have the need for both these things now.