View previous topic :: View next topic |
Author |
Message |
en6jcsw
Joined: 03 Aug 2004 Posts: 6
|
Posted: Tue Aug 03, 2004 1:39 pm Post subject: Re: [bascom] moving code appears to change operation (AVR) |
|
|
Hi everyone,
This is a copy of a message I sent to the email-based mailing list, in case anyone in this forum has any advice they can give.
I don't know how to do attachments in this forum, so the files can be downloaded from http://www.copleyscientific.co.uk/bascom/bascom.html
Original messages follow:
Thanks for your advice Brian and Adrian, I've got a copy of AVRStudio now, and done the following:
1. I cut the program down to as few lines as possible, whilst retaining the error.
2. I loaded the new .obj file into AVRStudio, and found the following:
Routine_one
39: Cursor On
+0000008C: E08C LDI R24,0x0C Load immediate
+0000008D: 940E0111 CALL 0x00000111 Call subroutine
Routine_two
48: Cursor On
+0000009C: E08E LDI R24,0x0E Load immediate
+0000009D: 940E0111 CALL 0x00000111 Call subroutine
I don't know much about assembler, but I would guess that R24 is being loaded with a value representing the cursor being on or off - so why is it different in these two cases?
I've attached the .bas and the .obj files to this email - the program is very small now, so if anyone could take a look and find out where I'm going wrong I'd really appreciate it - and Mark if you're reading this, I know you're very busy but I've tried to make the program as small as possible so that spotting any mistakes should be easier, any assistance would be (very) gratefully received!
Thanks,
Jon
> -----Original Message-----
> From: owner-bascom@grote.net [mailto:owner-bascom@grote.net]On Behalf Of
> Jon Wright
> Sent: Monday, August 02, 2004 1:25 PM
> To: bascom@grote.net
> Subject: [bascom] moving code appears to change operation (AVR)
>
>
> Hello,
>
> I'm running the following piece of code as a subroutine within a larger
> program. On line 14 is 'Cursor On', but it only runs at certain times...
> I was making a new menu, similar to this one, so I copied the whole
> subroutine, and gave it a different name. Then I called it from exactly the
> same place as I had been calling the first subroutine, and the cursor didn't
> come on. It does come on if I put 'Cursor On' twice, _OR_ if I move the
> subroutine above the one I ran first within the code.
> I've tried adding and deleting a space from each line in the routine, as I
> saw earlier in the list there were concerns over cut/pasted code, but that
> didn't make any difference.
> I'd really appreciate some help with this one - it's got me very confused!
>
> Thanks,
>
> Jon
>
> Enter_shot_number:
> Char(1) = 8
> Char(2) = 9
> Char(3) = 10
> Input_length = 3
> Cursor_position = 1
> Cls
> Upperline
> Lcd " Enter number of"
> Lowerline
> Lcd " shots in this test"
> Locate 3 , Char(1)
> Lcd Number_of_shots
> Locate 3 , Char(1)
> Cursor On
> Do
> Do
> Gosub Read_keypad
> Loop Until Keypad <> 16
> Select Case Keypad
> Case 13
> If Cursor_position > 1 Then
> Number_of_shots = 0
> D = 1
> Cursor_position = Cursor_position - 1
> For A = Cursor_position To 1 Step -1
> Print "a=" ; A
> C = Input(a) * D
> Number_of_shots = Number_of_shots + C
> D = D * 10
> Next A
> End If
> Print "number of shots=" ; Number_of_shots
> Gosub Start_test
> Return
> Case 10
> Return
> Case 11
> If Cursor_position > 1 Then
> Input(cursor_position) = 0
> Cursor_position = Cursor_position - 1
> Locate 3 , Char(cursor_position)
> Lcd " ";
> Locate 3 , Char(cursor_position)
> End If
> Case 0 To 9
> If Cursor_position = 1 Then
> For A = 1 To Input_length
> Lcd " ";
> Next A
> Locate 3 , Char(1)
> End If
> If Cursor_position <= Input_length Then
> Lcd Keypad;
> Input(cursor_position) = Keypad
> Cursor_position = Cursor_position + 1
> End If
> End Select
> Loop
> Return
>[url][/url] |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Aug 03, 2004 10:51 pm Post subject: |
|
|
Hi,
As the CURSOR commands has a number of options, the compiler holds a variable with the setting you make. For example for CURSOR ON, CURSOR BLINK , etc.
But the code must be placed as encountered by the compiler.
This is an effect i discovered later.
There are 2 solutions :
- change the CURSOR statement and you need to provide all the other params as well because you can not change only one without effect on te other bits. (in order not to break compatibility, i will add a new option)
- you use _LCD_CONTROL and you load R24 with the proper value:
const cCursorOn = 8 + 4 + 2
const cCursorOff = 8 + 4
ldi r24, cCursorOn
rcall _lcd_control
use the proper constant to set the cursor on/off, display and blink on/off. _________________ Mark |
|
Back to top |
|
|
en6jcsw
Joined: 03 Aug 2004 Posts: 6
|
Posted: Wed Aug 04, 2004 8:48 am Post subject: |
|
|
Thank you very much Mark, I'll use the _lcd_control as you suggested.
Best regards,
Jon |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|