Gosub error on MacAXEPad

sampsonij

New Member
Whenever I use a gosub command in a program, the Macaxepad stops working and will not program the platform. The mac axepad states that the hardware cannot be found.

if I comment out the gosub it downloads the code. Is anyone else having this issue?
Attached is a sample program, that causes the problem




'New application to write the time to the
symbol COM = 44 'comma
symbol RET = 13 'carriage return
symbol LFEED = 10 'line feed


main:
b13=0
'set the clock
'Only used if required
'
'i2cslave %11010000,i2cslow, i2cbyte
'writei2c 0, ($20, $33, $16, $02, $02, $03, $09, $10)
'pause 100
'low 5


looppoint:
i2cslave %11010000,i2cslow, i2cbyte
readi2c 0,(b0,b1,b2,b3,b4,b5,b6)
'debug b3
'debug b4
'debug b5
'debug b6

let b7 = b0 & %11110000 / 16 * 10
let b0 = b0 & %00001111 + b7

let b7=b1 & %11110000 / 16 * 10
let b1 = b1 & %00001111 + b7
let b7 = b2 & %11110000 / 16 * 10
let b2 = b2 & %00001111 + b7

'debug secs
'debug mins
'debug hours

readtemp 7, w4 'Read the temp from pin 7 to b1
readadc 0,W5 'Read port 0 ligh

serout 7,n2400,("Time = ",#b2,":",#b1,":",#b0, " Date = ",b3, " ", #b4,"/",#b5,"/",#b6," Temp= ",#w4," Light =",#w5,RET,LFEED)



i2cslave %10100000,i2cfast, i2cbyte
gosub write2memory


readi2c 0,(w5)
serout 7,n2400,(#w5," ")
readi2c 1,(w5)
serout 7,n2400,(#w5," ")
readi2c 2,(w5)
serout 7,n2400,(#w5," ")
readi2c 3,(w5)
serout 7,n2400,(#w5," ")
readi2c 4,(w5)
serout 7,n2400,(#w5," ")
readi2c 5,(w5)
serout 7,n2400,(#w5," ")
low 2
high 3
pause 2480 'Wait
low 3
high 2
pause 2500
'pause 55000
goto looppoint ' goto start and do it again

write2memory:
writei2c b13,(w0)
pause 20
b13=b13+1
writei2c b13,(w1)
pause 20
writei2c b13,(w2)
b13=b13+1
pause 20
writei2c b13,(w3)
b13=b13+1
pause 20
writei2c b13,(w4)
b13=b13+1
pause 20
writei2c b13,(w5)
b13=b13+1
debug w2
if b13>200 then resetb
return
resetb:
b13=0
return
 

hippy

Technical Support
Staff member
I do not have a Mac to test with but the code downloads as expected using WinAXEpad when the GOSUB is present.

What happens if you try to download the following program -

#picaxe28x1
Do
Gosub Nothing
Loop
Nothing:
Return
 

sampsonij

New Member
Exactly as before Gosub cannot be used.

I am using an 18x chip but I believe this can use gosub statements.

The process is as follows
1. enter code (Used your example or the one from the online manual)
2. Select program (Works perfectly with my code where Gosub is not present)
3. Program window appears
4. Error box states the hardware cannot be found

If I immediatly change back to my working program, I can upload the code.
 

hippy

Technical Support
Staff member
Sorry, that "#Picaxe28x1" crept in there by mistake. If without that, or with it changed to #Picaxe18X, it will not download but will without a Gosub then something very odd is going on with the MacAXEpad software or your hardware setup.

I cannot see any connection between what the program actually is and the download process that follows but we will investigate this.

Could you please you take a screen shot or tell us exactly what the "Hardware not found" error box says. Thanks.
 

sampsonij

New Member
Gosub and return from for next loop not working

As previously stated, the editor and additionally the command line compiler will not work on my mac with a gosub command. Additionally my program will not return from a for next loop when programmed from the MAC

I have attached a screen shot of the problem the exact error message is

Download for PICAXE-18X on subserial-000021FA Failed
Error: Hardware not found on /dev/tty.usbserial-000021FA!

The cable is a USB - 3.5mm AXE-27 lead which works perfectly unless a gosub is used in the code.

I am using version 0.6 of the compiler Version 0.1.2 of MacAxePad
and Firmware v8.6 on the Picaxe-18X. The firmware version was the next command issued after trying to download the code.


Another issue
Using my orginal code I have a for next loop. This loop is activated from an if statement within a subroutine. When the program variable reaches a value it should return to the orginal point but never does.
I have attached this code, you will notice that the gosub statements are missing, and I could really use them :)
 

Attachments

hippy

Technical Support
Staff member
Thanks for the screenshot and additional information. This is a peculiar issues which we will investigate. We have used MacAXEpad and so have other customers and I haven't heard of any similar problems.

The only suggestion I have at the moment is to use the Hard Reset procedure when downloading. It may be that the first downloaded programs locks the 18X, the next download which has a GOSUB won't download but 'loosens the chip up' so the download after that without a GOSUB does work. Thus giving the impression it is a GOSUB issue when it is something else.

To do a Hard Reset download - power the 18X off, wait a few seconds, initiate a download of a program which includes a GOSUB, when the download window appears and shows "Searching for hardware on ..." as its last line, power the 18X up again. If that doesn't work, repeat the process without removing the GOSUB. It may not work but I cannot think of anything else to try at the moment.

The FOR-NEXT problem seems to be a related issue - with the GOSUB commented out, the program will not behave as expected.
 
Last edited:

hippy

Technical Support
Staff member
Do you have any other sized PICAXE chips you can try with ?

The only other information I can think of at the moment which may help get to the bottom of this is -

What hardware are you using, is it a Rev-Ed PCB or something else ?
How is it powered ?
Which version of the Mac OS are you using ?
Is it an Intel or PowerPC platform ?
 

sampsonij

New Member
I dont have any other chips. If you want to send me some I would be happy to test your software.

The unit is the AXE110P card purchased ready built from tech-supplies. It is currently running my software reading light, temp and time from the RTC. The output goes to a serial port. The code was previously attached.

The unit is powered via Barreries and works well with them. The code I have is happly reading a RTC from the 1307 chip, so I know the batteries are good!

I am using 10.5.6 (The latest version with full patches) on an Intel chip. It is a Macbook Pro 2.4Ghz

I am happy to help you debug this problem if you have code that will output relevent debug logs which I can send to you.
 

Technical

Technical Support
Staff member
There does seem to be a Mac specific issue with gosub in the compiler, which is a bit strange as exactly the same code is used in the Mac/Windows/Linux compilers!

We'll look into it, but for now try adding the extra line

interrupt: return

at the bottom of your program. This may well fix the issue.

Your .bas file attachment does not work as you use a 'goto' followed by 'return'. This causes a stack pop with no data, and so is a user program fault, not a compiler fault.
 

sampsonij

New Member
Adding the
interrupt: return

at the bottom of the code now allows the Gosub routine. I think we have found the issue with the compiler.

As to the other issue I am debugging the problem now
 

riccoman

New Member
I've been experiencing the same problem (unable to find hardware) with AXEPad 0.1.2 on my Mac Powerbook running OSX 10.5.6 and trying to program the following into a 8M with firmware version 9.2 and compiler version 0.6 using the AXE027 usb cable:


main:
gosub testsub
end

testsub:
return

Comment out the gosub statement and it programs fine. I've tried swapping chips too.
 

unstableair

New Member
This problem seems to be back at MacAXEpad Version 1.1.0 as I my programs with gosubs won't load onto an 8M unless I append the 'interrupt: return'
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

Thanks for the feedback and we will look into that.
 

millo lopez

New Member
Hi,
I'm new to PICAXE and to the forum. I just want to report that I also have this issue using MacAXEpad version 1.1.0. The interrupt: return fix works for me using a picaxe20X2.

By the way hippy, I've learned a ton from your posts, thanks!
 
Top