Error: #Directive Error - #Slot Already Used

NOS9

New Member
Hi,

Im experimenting with the slots on the 28x2 picaxe microcontroller, and after looking at the forum in relation to slots, ive added some code to set slot locations i want the code to be downloaded too, but im getting an error.

Code:
#Picaxe 28x2
#Slot 0

<Intro Code & Varibles>

run 2

#Slot 2
<Main Program Code>
If leave the #Slot 0, the programmer spits an error at me, but if i remove the #Slot 0, the programmer fails to download to #slot 0.

I cleared the hardware memory, and now the code wont download to slot 0, and the microcontroller fails to boot at all

I did a search on the subject, but found nothing of relation, and so i download the most recent picaxe programming editor v5.3.1.

I looked at x2 manual, and it has a #slot 0 command, and the program runs correctly if i remove the slot commands all together.

Any suggestion would really be welcome, thank you.
NOS
 

tarzan

Senior Member
Hi NOS9

You can only have one directive at a time for “#slot”.
If you want to keep all slots in one file you need to use “#define, #ifdef, #endif”.
An example can be found here: http://www.picaxeforum.co.uk/showthread.php?t=13439

Code:
[SIZE="2"][FONT="Verdana"]	#DEFINE SLOT_0 	'DOWNLOAD EACH SLOT INTURN
	'#UNDEFINE SLOT_0
	'#DEFINE SLOT_1
	#UNDEFINE SLOT_1

#IFDEF SLOT_0
	#SLOT 0

	MAIN:
		'CODE HERE
	GOTO MAIN

#ENDIF
 
#IFDEF SLOT_1
	#SLOT 1

	MAIN:
		'CODE HERE
	GOTO MAIN

#ENDIF[/FONT][/SIZE]
 

NOS9

New Member
Hi Tarzan,

I tried your suggestion, and i also downloaded and looked over the example code.

I made the changes to my code, and now im not getting the error, but when i download my code to the microcontroller, i get a Serial Terminal Window appear on the PICAXE Programmer Editor, and the microcontroller program is not running correct.

If i have the code like this, then picaxe microcontroller fails to run my program as it should:
Code:
#com 1
#terminal 9600
#define slot_0
#undefine slot_0
#define slot_1
#undefine slot_1
#define slot_2
#undefine slot_2
#define slot_3
#undefine slot_3
If i use the code like noted in your single bas file slots example, the microcontroller loops slot 0.

Code:
#com 1
#terminal 9600
#define slot_0
'#undefine slot_0
'#define slot_1
#undefine slot_1
'#define slot_2
#undefine slot_2
'#define slot_3
#undefine slot_3
I placed the code need to designate the borders of code for each slot.
Code:
#ifdef slot_0
#slot 0
<code>
#endif
Is the command to jump to a slot
Code:
Run 1 'Run Slot 1
Thank you
NOS
 

MartinM57

Moderator
..and you've commented in/out all the right #define/#undefine's and downloaded the code to the PICAXE multiple times to get the slots filled with what you want?
 

hippy

Ex-Staff (retired)
The best way to approach this is by having the two slot programs in separate program files ...

Code:
' Slot0.bas
#Picaxe 28X2
#Terminal 9600
#Slot 0

SerTxd( "In slot 0", CR, LF )
Run 2
Code:
' Slot2.bas
#Picaxe 28X2
#Terminal 9600
#Slot 2

SerTxd( "In slot 2", CR, LF )
Run 0
Download slot2.bas then slot0.bas. When they run you should see the program alternating between slot 0 and 2.

To combine into a single source code you need to wrap each slot's code in a #IFDEF-#ENDIF like ...

Code:
#Picaxe 28X2
#Terminal 9600

#IfDef LOAD_SLOT0 Then
  #Slot 0
  SerTxd( "In slot 0", CR, LF )
  Run 2
#EndIf

#IfDef LOAD_SLOT2 Then
  #Slot 2
  SerTxd( "In slot 2", CR, LF )
  Run 0
#EndIf
You then need to add a "#Define LOAD_SLOT0" at the top of the program and download. That will load Slot 0. You then need to change to "#Define LOAD_SLOT2" and download again. That will load Slot 2.

There are other ways to define which of the two slots to load as Tarzan describes. Key to all mechanisms is that you must configure for and download each slot.
 

NOS9

New Member
Thanks Hippy,

Ill check my code over some more as i have alot of it, and try your suggestions. It seems like the second slot is not being downloaded too, as the download time is smaller in comparison to the whole program in a single slot.

It might be ill have to break the file up in to seperate files for each slot, but im hoping i wont have to...

Why does the terminal screen load up after the program is downloaded to the microcontroller? Whats it used for other that for making a terminal connection, i imagine.

Thanks again
Nos.
 

hippy

Ex-Staff (retired)
Download of each slot will usually be less than the download for all code in a single slot. If you don't have your #DEFINE and #IFDEF commands correct - particularly the names used - then you could be downloading a blank program. You can do a Syntax Check to see the size of each slot program and this will usually be a good indication if that is the case.

Splitting a program for multiple slots into individual files is often easier than using a single file, at least that's my experience. Rather than having to frequently edit #DEFINE commands, commenting code in and out of programs, having to remember which slot has been edited or changed and consequently needs to be downloaded, under Programming Editor and AXEpad you can simply open both files, switch between the two slot programs and click the program button.

There are other advantages to the 'one file per slot program' approach; less code in each slot and fewer #IFDEF commands which keeps it easier to understand, and if others are to use the program it can be far easier to explain the sequential downloading of both slot programs than explain the editing required to achieve the same.
 

Technical

Technical Support
Staff member
Why does the terminal screen load up after the program is downloaded to the microcontroller? Whats it used for other that for making a terminal connection, i imagine.
You can turn it off my using View>Options menu or simply including the line
#terminal off

It is generally used for displaying 'sertxd' commands on screen
 
Top