SX28 Memory Problem
Alex-M
Posts: 9
Hi!
I have a problem with the memory in the SX28. I'm using the SX-Key v3.3.0.
If I open the "Memory usage" (under "Run" in the menu), it looks like this:
Page 0 - 0 to 551
lllllllllllllllllllllllllllllllllllllllll 489 bytes
Page 1 - 512 to 1023
l_______________l 0 bytes
Page 2 - 1024 to 1535
l_______________l 0 bytes
Page 3 - 1536 to 2047
l_______________l 1 bytes
So the program works fine, but I removed a lot of code to make it work! If I put it back i got memory usage on "Page 1" and the program do not work!
Do I need to tell the SX-Key that I using "Page 1"? Or do I need to put somthing in the code to make "Page 1" work?
Thanks in advace
Alex-M
I have a problem with the memory in the SX28. I'm using the SX-Key v3.3.0.
If I open the "Memory usage" (under "Run" in the menu), it looks like this:
Page 0 - 0 to 551
lllllllllllllllllllllllllllllllllllllllll 489 bytes
Page 1 - 512 to 1023
l_______________l 0 bytes
Page 2 - 1024 to 1535
l_______________l 0 bytes
Page 3 - 1536 to 2047
l_______________l 1 bytes
So the program works fine, but I removed a lot of code to make it work! If I put it back i got memory usage on "Page 1" and the program do not work!
Do I need to tell the SX-Key that I using "Page 1"? Or do I need to put somthing in the code to make "Page 1" work?
Thanks in advace
Alex-M
Comments
Subroutine calls are a bit tricky because the target address must be in the first half of the page. I normally put a jump table at the beginning of my program and do my calls through the jump table. I always use the long version for jumps and calls even though most of my jumps and calls may be in the same page. It's just easier for me to not have to worry about page boundaires.
Keep in mind that long jumps take an extra cycle, and they will change the timing of the loops. This is important to remember for timing loops.
Dave
I seen other programs that works fine and the are using 2 or 3 pages and I can't nind any thing special in there code.
Some times the program works for like a minute.
In the beginig of the program it tests a LED for 1 sec but somtimes (when the program works) the LED is on for 2 to 5 sec instead of 1 sec. (In the code "PAUSE 1000")
It may be an option that works for you. If not and your code is something you can post then others can try to reproduce the problem to help find a way around it.
Robert
It would help if you post your code. Otherwise, we can only guess about what the problem is. Hopefully, someone more familiar with SX/B will respond soon.
'Panel 16ch Tx
'Version 1.0
'Config
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'I/O
Sio PIN RA.0
Spkr PIN RA.2
BtnAll PIN RA.1
Btn1 PIN RB.0
Btn2 PIN RB.1
Btn3 PIN RB.2
Btn4 PIN RB.3
Btn5 PIN RB.4
Btn6 PIN RB.5
Btn7 PIN RB.6
Btn8 PIN RB.7
Btn9 PIN RC.0
Btn10 PIN RC.1
Btn11 PIN RC.2
Btn12 PIN RC.3
Btn13 PIN RC.4
Btn14 PIN RC.5
Btn15 PIN RC.6
Btn16 PIN RC.7
'Variablar
Cmd VAR Byte
Btn1_State VAR Bit
Btn2_State VAR Bit
Btn3_State VAR Bit
Btn4_State VAR Bit
Btn5_State VAR Bit
Btn6_State VAR Bit
Btn7_State VAR Bit
Btn8_State VAR Bit
Btn9_State VAR Bit
Btn10_State VAR Bit
Btn11_State VAR Bit
Btn12_State VAR Bit
Btn13_State VAR Bit
Btn14_State VAR Bit
Btn15_State VAR Bit
Btn16_State VAR Bit
PROGRAM Start
Start:
'
Main:
'BtnLed/Read
INPUT Btn1
IF Btn1 = 1 THEN GOTO Btn1_Click
IF Btn1_State = 1 THEN
HIGH Btn1
ENDIF
INPUT Btn2
IF Btn2 = 1 THEN GOTO Btn2_Click
IF Btn2_State = 1 THEN
HIGH Btn2
ENDIF
INPUT Btn3
IF Btn3 = 1 THEN GOTO Btn3_Click
IF Btn3_State = 1 THEN
HIGH Btn3
ENDIF
INPUT Btn4
IF Btn4 = 1 THEN GOTO Btn4_Click
IF Btn4_State = 1 THEN
HIGH Btn4
ENDIF
INPUT Btn5
IF Btn5 = 1 THEN GOTO Btn5_Click
IF Btn5_State = 1 THEN
HIGH Btn5
ENDIF
INPUT Btn6
IF Btn6 = 1 THEN GOTO Btn6_Click
IF Btn6_State = 1 THEN
HIGH Btn6
ENDIF
INPUT Btn7
IF Btn7 = 1 THEN GOTO Btn7_Click
IF Btn7_State = 1 THEN
HIGH Btn7
ENDIF
INPUT Btn8
IF Btn8 = 1 THEN GOTO Btn8_Click
IF Btn8_State = 1 THEN
HIGH Btn8
ENDIF
INPUT Btn9
IF Btn9 = 1 THEN GOTO Btn9_Click
IF Btn9_State = 1 THEN
HIGH Btn9
ENDIF
INPUT Btn10
IF Btn10 = 1 THEN GOTO Btn10_Click
IF Btn10_State = 1 THEN
HIGH Btn10
ENDIF
INPUT Btn11
IF Btn11 = 1 THEN GOTO Btn11_Click
IF Btn11_State = 1 THEN
HIGH Btn11
ENDIF
INPUT Btn12
IF Btn12 = 1 THEN GOTO Btn12_Click
IF Btn12_State = 1 THEN
HIGH Btn12
ENDIF
INPUT Btn13
IF Btn13 = 1 THEN GOTO Btn13_Click
IF Btn13_State = 1 THEN
HIGH Btn13
ENDIF
INPUT Btn14
IF Btn14 = 1 THEN GOTO Btn14_Click
IF Btn14_State = 1 THEN
HIGH Btn14
ENDIF
INPUT Btn15
IF Btn15 = 1 THEN GOTO Btn15_Click
IF Btn15_State = 1 THEN
HIGH Btn15
ENDIF
INPUT Btn16
IF Btn16 = 1 THEN GOTO Btn16_Click
IF Btn16_State = 1 THEN
HIGH Btn16
ENDIF
PAUSE 1
GOTO Main
'
Btn1_Click:
IF Btn1_State = 1 THEN
Btn1_State = 0
Cmd = 010
ELSE
Btn1_State = 1
Cmd = 011
ENDIF
GOTO Send
'
Btn2_Click:
IF Btn2_State = 1 THEN
Btn2_State = 0
Cmd = 020
ELSE
Btn2_State = 1
Cmd = 021
ENDIF
GOTO Send
'
Btn3_Click:
IF Btn3_State = 1 THEN
Btn3_State = 0
Cmd = 030
ELSE
Btn3_State = 1
Cmd = 031
ENDIF
GOTO Send
'
Btn4_Click:
IF Btn4_State = 1 THEN
Btn4_State = 0
Cmd = 040
ELSE
Btn4_State = 1
Cmd = 041
ENDIF
GOTO Send
'
Btn5_Click:
IF Btn5_State = 1 THEN
Btn5_State = 0
Cmd = 050
ELSE
Btn5_State = 1
Cmd = 051
ENDIF
GOTO Send
'
Btn6_Click:
IF Btn6_State = 1 THEN
Btn6_State = 0
Cmd = 060
ELSE
Btn6_State = 1
Cmd = 061
ENDIF
GOTO Send
'
Btn7_Click:
IF Btn7_State = 1 THEN
Btn7_State = 0
Cmd = 070
ELSE
Btn7_State = 1
Cmd = 071
ENDIF
GOTO Send
'
Btn8_Click:
IF Btn8_State = 1 THEN
Btn8_State = 0
Cmd = 080
ELSE
Btn8_State = 1
Cmd = 081
ENDIF
GOTO Send
'
Btn9_Click:
IF Btn9_State = 1 THEN
Btn9_State = 0
Cmd = 090
ELSE
Btn9_State = 1
Cmd = 091
ENDIF
GOTO Send
'
Btn10_Click:
IF Btn10_State = 1 THEN
Btn10_State = 0
Cmd = 100
ELSE
Btn10_State = 1
Cmd = 101
ENDIF
GOTO Send
'
Btn11_Click:
IF Btn11_State = 1 THEN
Btn11_State = 0
Cmd = 110
ELSE
Btn11_State = 1
Cmd = 111
ENDIF
GOTO Send
'
Btn12_Click:
IF Btn12_State = 1 THEN
Btn12_State = 0
Cmd = 120
ELSE
Btn12_State = 1
Cmd = 121
ENDIF
GOTO Send
'
Btn13_Click:
IF Btn13_State = 1 THEN
Btn13_State = 0
Cmd = 130
ELSE
Btn13_State = 1
Cmd = 131
ENDIF
GOTO Send
'
Btn14_Click:
IF Btn14_State = 1 THEN
Btn14_State = 0
Cmd = 140
ELSE
Btn14_State = 1
Cmd = 141
ENDIF
GOTO Send
'
Btn15_Click:
IF Btn15_State = 1 THEN
Btn15_State = 0
Cmd = 150
ELSE
Btn15_State = 1
Cmd = 151
ENDIF
GOTO Send
'
Btn16_Click:
IF Btn16_State = 1 THEN
Btn16_State = 0
Cmd = 160
ELSE
Btn16_State = 1
Cmd = 161
ENDIF
GOTO Send
'
Send:
SEROUT Sio, T9600, Cmd
PAUSE 500
GOTO Main
'
END
Seems like it should be OK, though I haven't had a chance to check it in the current compiler yet.
What version of SX/B are you using?
I looked at other programs that are very large and I can't see any special comands. And they works fine.
Are you expecting ASCII codes on the serial port. You are sending numbers larger than 128 for buttons 13 through 16. These numbers have the most significant bit set. What kind of device is at the other end of the serial port?
; *** COMPILED WITH SX/B VERSION 1.51.03 09/21/2006 ***
Every button have an LED. When I press a button it shuld lit up it's own LED. But some times it stucks in on or off state. And it takes a minute or so for the program to start.
The numbers(Cmd = 141 (Ch14 ON)) are sent to a nother sx28 that controls the rest of the system. Nothing to worry about now.
Here is a nother code I used to test if i cuold control buttons this way, and it works perfectly fine:
'Namn
'Config
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'I/O
Spkr PIN RA.1
Btn1 PIN RC.0
Led1 PIN RC.1
'Variablar
i VAR Byte
Btnspd VAR Byte
Mode1 VAR Byte
Btn VAR Byte
PROGRAM Start
Start:
Mode1 = 0
Main:
IF Mode1 = 1 THEN
HIGH Btn1
ENDIF
INPUT Btn1
IF Btn1 = 1 THEN
GOTO Btn1_Click
ENDIF
GOTO Main
Btn1_Click:
IF Mode1 = 1 THEN
Mode1 = 0
LOW Led1
ELSE
Mode1 = 1
HIGH Led1
ENDIF
PAUSE 500
GOTO Main
END
; *** COMPILED WITH SX/B VERSION 1.51.03 09/21/2006 ***
The softwere I use when i'm programing the SX28 is SX-Key v3.3.0
I found 2.00.31 in the old forums:
http://forums.parallaxinc.com/forums/default.aspx?f=7&m=323767
and the new forums:
http://forums.parallax.com/showthread.php?t=109886
Jim
Robert
I think I know what the problem is!
I only tested 1 chanel (ch9) and I have only one 10k resistor on that chanel I'm testing. The other chanels is not conected to any thing so they don't know if the are 1 or 0. So they act randomly and the program is working with setting the state on all the other chanels instead of setting ch9.(Btn9_State)
If I conect all buttons maby It works.
That's my theory.