40x2 making me go bald

Steve2381

Senior Member
Hey all

I have a 40x2 in my truck controlling all the lighting.... worked fine for 5 years.
Yesterday the garage broke it.

So, trying to re-upload the 4x slot program to the chip and I spent the last 3 hours trying to do it. Just about to put a hammer through it.

First of all... took 2 hours for my laptop to allow the AXE027 programming lead to work for some bizarre reason... mixed in with Win 10 updates.

But... now I am in PE6 and have the 4 program slots open. But, when I ask it to upload to the chip (using one on my AXE091 dev board to start), it says it doesn't understand the command Slot#0?

Unknown directive is the actual error?

Search for the chip... it finds the 40x2, so I am not sure why the command is not allowed. Has something changed in PE6 (Which I hate buy the way) from PE5?
PE5 just will not work on my machine anymore... it can't find the AXE027 lead.

Any suggestions?
Otherwise its reprogramming the whole thing tonight on an Arduino which seems a shame as its worked fine
 

hippy

Technical Support
Staff member
now I am in PE6 and have the 4 program slots open. But, when I ask it to upload to the chip (using one on my AXE091 dev board to start), it says it doesn't understand the command Slot#0?

Unknown directive is the actual error?
Not quite sure what the issue is there unless there's some invisible characters on the line. It works for me with PE6 using all sort of spacing and comments on the line.

If the directive is correctly specified, it may be that you don't have the 40X2 selected. Make sure you have the latest version of PE6.

Perhaps attach your code so we can test it, see if we get the same results.

As to PE5 no longer finding the AXE027; if PE6 can see it then PE5 should as well. PE5 won't see it if it's got a COM number greater than 16. That's a limitation of the Windows libraries which have to be used by PE5, one of the reason we moved to PE6.
 

Steve2381

Senior Member
Hi Hippy

Comms port in PE5 is usually 3 or 4. Certainly not over 16. It just will not find it.

No comments about my code! (this is one of 4 slots) I didn't know better back then.
I had to chop the end off... it wont allow such a long post of code, so this won't compile

Search for the chip and it finds a 40x2.
Try to load the code... I get

#slot0
^
Syntax error on line 8 at position 1

Error: Unknown Directive


Hmm

Code:
;Ford Ranger Lighting and Accessory Controller
;May 2013
;40x2 Main processor coding
;Slot 0

#slot0

low d.3									'Set relay for power control

setfreq m16

symbol jumpslot= b6

gosub readdata

fvrsetup FVR2048								;set the ADC reference voltage to 2.048v
adcconfig %1000								;Vref+ is FVR, Vref- is 0V


if jumpslot=>1 and jumpslot=<5 then 				'If returning from another slot, send to the main menu
	gosub draw_main_menu
	goto main_loop
	endif
	
if jumpslot=7 then goto pin_lock

#no_data									'Enable to stop it clearing the eeprom

dirsA = %11111111								;1=Output   0=input
dirsB = %11110010			
dirsC = %01110111		
dirsD = %01100011

Symbol pinE  = pinb.7 : Symbol dirE  = dirb.7  			; 0 = Idle      1 = Active
Symbol pinRS = pinb.5 : Symbol dirRS = dirb.5  			; 0 = Command   1 = Data

Symbol pinD4 = pinb.6 : Symbol dirD4 = dirb.6  		 	; LCD Data Line 4
Symbol pinD5 = pinc.5 : Symbol dirD5 = dirc.5   		; LCD Data Line 5
Symbol pinD6 = pinc.4 : Symbol dirD6 = dirc.4   		; LCD Data Line 6
Symbol pinD7 = pinB.1 : Symbol dirD7 = dirB.1   		; LCD Data Line 7

symbol Bluetoothdata=b28						'Set up the bluetooth variable

'_______________________________________________________________________________________________


PowerOnReset:

Gosub InitialiseLcd


'B0 is used as variable for Oled
symbol sfx = b1								;SFX 1=on 0=off
symbol countloop = b2							;counter loop for general timing use
countloop=0
symbol rearlights = b3
'b4 is used as a for loop variable
symbol instantmode= b5							;What lights are on full beam

symbol drlstat=b7								;Status of the ignition input
symbol outer130stat=b8							;status of the full beam input
symbol inner130stat=b9
symbol DRLs = b10
symbol hazard = b11
symbol Rearultrasonics = b12
symbol Sparetyreloop = b13
symbol Pager = b14
symbol Rearlidlock = b15
symbol screensaveron = b16
symbol voltageoff = b17
symbol pin1 = b18
symbol pin2 = b19
symbol pin3 = b20
symbol pin4 = b21
'b22,b23,b24 used as variables for bintoascii conversion
symbol line=b25								'Value of the required display line starting point
symbol menu = b26	
symbol rearworkstat = b27						'Status of the rear work lights (1=on)			
symbol sequence=b29							'Which headlight sequence is selected (0=off)
symbol quote=b30								'Required text to display on LCD
symbol outerroofstat=b31
symbol innerroofstat=b32
symbol abarstat=b33
symbol flashcheck=b34							'Logs whether its checked for a headlight flash
symbol reqlight=b35							'Which light to flash (retrived from memory)
symbol readaddress=b36							'Used in the flash lights routine
symbol flashdelay=b37							'Time between flashes of sequenced lights
symbol general=b38							'General use variable
symbol ledbarover=b39							'Led bar over-ride  1=on
symbol blueleds=b40							'Whether blue leds are on
symbol ignlock=b41							'Whether ignition lock is on
symbol blueledstat=b42							'Status of blue leds
'b43 used as general variable
symbol flashdelaytotal=w22						'Flash delay after multiplication
symbol voltagevalue=w23							'Current value of input voltage
symbol voltagetarget=w24						'Voltage target to switch off lights
'b50 used as general variable
symbol emergencyoff=b51							'If this equals 1 then switch of all lights due to low battery
symbol screensaver=w26							'Screensaver is active if this equals 1
symbol lightmode=b54							'The 4x4 quick change mode (AUX)
symbol screensaverdelay=b55						'Slows the occurances of checking the screensaver
menu=1									;Menu counter
screensaver=0

system_reset:								'Holding ENTER for 60 seconds resets the pincode  (used the screensaver variable)
if pind.4=1 then 
	screensaver=screensaver+1
	endif
	
if screensaver>65000 then
	write 10,1
	write 11,1
	write 12,1
	write 13,1
	sound c.6, (114,50)
	goto reset_skip
	endif

if pind.4=1 then system_reset

reset_skip:

screensaver=0

'write 0,1	'Sound
'write 1,3	'Rear lights
'write 2,2	'DRLs - Default is on with ignition
'write 3,0	'Lightmode					Whether the lights work on full beam (AUX ON/OFF)
'write 4,0	'Rear Ultrasonics
'write 5,0	'Spare tyre loop
'write 6,0	'Pager
'write 7,0	'Rear lid lock
'write 8,1	'Blue leds					On as default
'write 9,1	'Voltage auto-off				On as default
'write 10,1	'Pin 1
'write 11,1	'Pin 2
'write 12,1	'Pin 3
'write 13,1	'Pin 4'
'write 14,1 'Sequence selected			1 set as default
'write 15,1 'Instant mode				What lights are on full beam when they are on
'write 16,4  'Flash delay				1 set as default
'write 17,120 'Voltage target				'Set as 12v as default 


'write 199,5,1,0,4,6,3,2				'Sequence 1				'setup the sequences
'write 209,0,1,5,4,2,3,6				'Sequence 2
'write 219,3,2,1,0,4,6,5				'Sequence 3
'write 229,4,0,1,5,3,2,6				'Sequence 4
'write 239,0,1,2,3,4,5,6				'Sequence 5
'write 249,5,0,1,2,3,4,6				'Sequence 6	

gosub readdata

flashdelaytotal=flashdelay*100			'converted speed of flash

'rearlights=3						'This sets the rear lights to default igniton 'auto' mode

pause 200

jumpslot=7							' jump across and display startup message
run 3


'_________________________________________________________________________________________________________________________________

pin_lock:
jumpslot=0


if pin1=1 and pin2=1 and pin3=1 and pin4=1 then goto pin_skip			;If pin is disabled, skip to main menu
jumpslot=3
run 3



pin_skip:

gosub draw_main_menu

;__________________________________________________________________________________________________________________________________

Main_loop:
jumpslot=0

Gosub draw_arrow:	

do	
		
if pinc.7=1 then exit
if pind.4=1 then exit

;_________________________________________________________________________________________________________________________________

ignition_present_check:							;Shutdown system if ignition goes off


	fvrsetup FVR2048							;set the ADC reference voltage to 2.048v
	adcconfig %1000							;Vref+ is FVR, Vref- is 0V

	readadc10 d.7,voltagevalue					;Obtain reading from voltage input

	if voltagevalue>10 then
	voltagevalue=voltagevalue*10/46+10				;Calculation to obtain voltage (when no voltage is present, the calculation will show 6v - hence the reset)
	endif
	
	if sfx=1 and voltagevalue<60 then
	pause 1000
	gosub play_double_tone
	endif			
	
	if voltagevalue<60 then						;End code if voltage is under 6v
		pause 1000
		b0=%00000001: Gosub sendcmdbyte			'Clear display
		line=148
		quote=45
		gosub print2lcd
		pause 3000
		gosub clear3
		
		write 3,lightmode						'Store whether the full beam is in Aux on or Aux off mode
		
		high d.3							'Change state of supply relay to kill the 12v supply		
	
		end
		endif


;__________________________________________________________________________________________________________________________________	

if screensaveron=0 then 
	screensaver=screensaver+1	
	endif

if screensaver>2000 and screensaveron=0 then			'If no buttons are pressed after the count, then start displaying the screensaver
	screensaveron=1
	
	b0=%00000001: Gosub sendcmdbyte				'Clear display
	
	screensaver=0
	endif

screensaverdelay=screensaverdelay+1					'Increase the delay.  

if screensaveron=0 then skipped_screensaver_display

if screensaverdelay<>50 then skipped_screensaver_display
 

Steve2381

Senior Member
That command must have changed then.
This is the code loaded to the truck (its the only version I have). All my previous versions of the code (during development) all have the command written without the space.... it would have never worked?
Odd.

Anyway, thanks Hippy
 

hippy

Technical Support
Staff member
That command must have changed then.
Yes; the way directives are handled and parsed has altered slightly; spaces must be included after the directive name before the directive parameter. Not having a space was the option I never tested, never even thought about.

I cannot be sure but I suspect the change came when the pre-processor was implemented, was part of making that work as required and making things consistent when the pre-processor was not enabled.
 

Buzby

Senior Member
It's probably the same pre-processor too-clever stuff that broke #slot 4 on the 20X2.

Will we be getting a fix soon ?. It's a real pain having to lose the PPP_time/date stuff, as I need that in slot 4.
 

Circuit

Senior Member
It's probably the same pre-processor too-clever stuff that broke #slot 4 on the 20X2.

Will we be getting a fix soon ?. It's a real pain having to lose the PPP_time/date stuff, as I need that in slot 4.
This fascinated me; slots on the 20X2 - I am missing a trick here...but the information is so conflicting.

In the .PDF manual (manual 2 page 209) - "the 20X2 only supports slot 0". - eh? so it doesn't really support slots?
In the on-line Commands guide (directives) under the #slot directive; "Applies to 14M2, 18M2, 20M2, 20X2, 28X2, 40X2 " ...but none of the command details refers otherwise to the 20X2.

Perhaps Hippy could clarify these apparently conflicting statements.
 

Buzby

Senior Member
Yes, the 20X2 supports both #slot 4 and booti2c. The slot 4 is an external eeprom on the 20X2, and booti2c loads the code from that eeprom.

The project I'm working on now depends 100% on these facilities !.
 

hippy

Technical Support
Staff member
It's probably the same pre-processor too-clever stuff that broke #slot 4 on the 20X2.
It seems to be a compiler issue. It gives the same error if the pre-processor is disabled and by-passed.

Will we be getting a fix soon ?. It's a real pain having to lose the PPP_time/date stuff, as I need that in slot 4.
It has been logged and discussed so I would expect there to be a fix sometime though I don't have any schedule for when.
 

Buzby

Senior Member
It seems to be a compiler issue. It gives the same error if the pre-processor is disabled and by-passed.
I just tried copying the 2.4 version compiler from PE5 into PE6. It fails with the error 'Illegal command line switch '-m' !

Switch '-m' is not mentioned in either of the compilers .txt files, or even when '-h' is invoked.

What is switch -m ?, and can I turn it off ?

Cheers,

Buzby
 

hippy

Technical Support
Staff member
What is switch -m ?, and can I turn it off ?
The "-m" tells the compiler to output the simulation file with a .SIM extension. It isn't documented or in the "-h" list because it's not of relevance to anyone using the command line compilers, only relevant when the compilers are called by PE6. It cannot be turned off because PE6 needs to specify that.
 

Buzby

Senior Member
Ah well, back to PE5 !.

Or is there some way I can use the PPPstuff (from PE6) with the #slot 4 (from PE5) ?

Cheers,

Buzby
 
Top