Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

need help with Config Submode

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Sep 10, 2020 6:38 pm    Post subject: need help with Config Submode Reply with quote

I've altered my program to use Config Submode=new and it compiles with no errors until the end and gives:

Quote:
Error : 397 Line : 1 .ORG exceeds PC [74-6A] , in File : S:\_CD_Engineering Firmware Library\S1012-1A A30 A1300 PI3.BAS
Error : 397 Line : 1 .ORG exceeds PC [76-6C] , in File : S:\_CD_Engineering Firmware Library\S1012-1A A30 A1300 PI3.BAS
Error : 397 Line : 1 .ORG exceeds PC [78-6E] , in File : S:\_CD_Engineering Firmware Library\S1012-1A A30 A1300 PI3.BAS
Error : 397 Line : 1 .ORG exceeds PC [7A-70] , in File : S:\_CD_Engineering Firmware Library\S1012-1A A30 A1300 PI3.BAS


Had no issues with old submode. New submode freed up 5% of program memory (ATMEGA2560) - nice !!!

I don't even know where to start to address this error. Any help is appreciated!
Unfortunately, I can't post my code publicly, but here is the structure of the program:

original code with old submode:

Quote:
compiler directives
sub/function declares
config ports/pins
define constants
define globals
includes
- sub/function declares
- define constants
- define globals
- goto end of include
- subs/functions
- end of include

initializations
screen loops
- label:
- display stuff
- goto label

subs/functions
interrupt service routines
- label:
- do stuff
- return

End



new code with new submode:

Quote:
compiler directives
config ports/pins
define constants
define globals
includes
- define constants
- define globals
- subs/functions

subs/functions
initializations
screen loops
- label:
- display stuff
- goto label

interrupt service routines
- label:
- do stuff
- return

End



In summary, I moved the subs/functions to the top, removed declares, removed jump-overs in includes.

(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.3 )
Back to top
View user's profile AIM Address
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Thu Sep 10, 2020 6:56 pm    Post subject: Reply with quote

hi
I put all my sub, macro, and functions in some include file

I put declaration of include file
just befor the declaration of variables

Code:
$regfile = "m1284pdef.dat"
$crystal = 16000000

'$regfile = "m2560def.dat"
'$crystal = 16000000
$hwstack = 300                                              '300
$swstack = 250                                              '200
$framesize = 250                                            '300
Config Submode = New
Debug Off                                                   'On  'Off                                              'if you debug off you remove all print from USB port
'*****************************************************************
'*         CONFIG BUFFERED USART FOR  USB               *
'*****************************************************************
Config Com1 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Echo Off
Config Serialin0 = Buffered , Size = 30                     'RX from Terminal
Open "COM1:" For Binary As #1
Const Usb = 1
'M2560-------------------------------------
' RXD0= yellow to  PE0 tx0
' TXD0= Blue to    PE1 rx0
'M1284------------------------------------
 ' RXD0= yellow to  PD0
' TXD0=yellow to  PD1

'
'---serial port-------------------------------------------------------------------------------------------------------------
Config Com2 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0       '34800   modif le 12-02-2020
Open "COM2:" For Binary As #2
Config Serialin1 = Buffered , Size = 50
Config Serialout1 = Buffered , Size = 30
Const Nex = 2
'M2560-------------------------------------
' RXD1= yellow to  PD2        
' TXD1= Blue to    PD3            
'M1284------------------------------------
 ' RXD1= yellow to  PD3
' TXD1= Blue to  PD2


'------------les config------------------------------------------------------
Config Clock = User                                         ' we use Nextion RTC for the clock
Config Date = Dmy , Separator = Slash

'*******************************************************************************
'buzzer
Const Noteaigu = 1500                                       '2548
Const Notebasse = 14000                                     '1500       '4096       '400
Const Durdo = 200                                           '100 300
Const Durlent = 50
'Const Durdo = 600                                           '300
'Const Notela = 400       '200
'Const Durla = 1000
'atmega 2560 ---------
'Portbuzzer Alias PortH.5
'atmega 1284 ---------
'Portbuzzer Alias Portb.0
'Config Portbuzzer = Output
' we use the Nextion RTC basic display are not avaliable here============================
'********************
$include "declaration_nextion.inc"
$include "sub_macro_nextion#3.inc"
$include "nextiontimedate.inc"
$include "consthour.inc"
$include "clocksub.inc"


'*******variable to use with nextion**************************************************
Dim Tabreturn(30) As Byte                                   'array of bye returned by nextion
Dim Flagcar As Byte
Dim Page_id As Byte , Device_id As Byte , Event_id As Byte
Dim Letter_id As String * 10

' ---date Time var------------------------------------------------------------------------------------------

Dim Jsecond As Byte , Jminute As Byte , Jhour As Byte
Dim Oldsecond As Byte , Oldminute As Byte , Oldhour As Byte
Dim S_second As String * 2 , S_minute As String * 2 , S_hour As String * 2
Dim S_dow As String * 8
Dim Jday As Byte , Jmonth As Byte , Jyear As Byte
Dim S_month As String * 10
Dim S_day As String * 2
Dim Anne As Word , Jcentury As Word , S_anne As String * 4

Dim S_year As String * 4 , S_century As String * 4
Dim Dow As Byte                                             'day of week
 


and I write a project file witth all my include file


JP
Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Sep 10, 2020 7:07 pm    Post subject: Reply with quote

the .org is used for interrupts.
so you probably used 4 interrupts.
I think the ON ISR is embedded in some module that is later called.
you best move it outside the sub into the main module.
it could also be the case that it is a problem of the older version you use.

Some code does not belong inside a sub. things like this :

Code:
sub crazy(prm as byte)
  if prm=1 then
     $regfile="m88def.dat"
  else
    $regfile = "m32def.dat"
  end if
end sub
 

will not work since $regfile need to be known at compile time.
and the same for defining interrupts. this can not be inside a sub that might not be executed.

_________________
Mark
Back to top
View user's profile Visit poster's website
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Sep 10, 2020 8:08 pm    Post subject: Reply with quote

Quote:
the .org is used for interrupts.
so you probably used 4 interrupts.
I think the ON ISR is embedded in some module that is later called.
you best move it outside the sub into the main module.


Upgraded to 2.0.8.3

I'm using two interrupts (INT1, Timer1) and watchdog. I moved the configuration of the interrupts out of sub to top of main code.
Still get same errors.
Back to top
View user's profile AIM Address
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Sep 10, 2020 8:31 pm    Post subject: Reply with quote

i assume you did not use .org your self with some asm ? Or that you modified the dat file?
you best send the code to support to have it checked,
support will not really look at your code, but just at the problem. and we have seen important code, sloppy code, etc.
when the ticket is closed we delete the code.

anyway the error you get is a check of the .org asm instruction that checks if the provided address is further away than the current location. if not, because it is backwards, it will give an error. this because you can not use .org on a location back in memory.
what is odd, is why you would not get this error before.

_________________
Mark
Back to top
View user's profile Visit poster's website
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Sep 10, 2020 8:43 pm    Post subject: Reply with quote

Quote:
i assume you did not use .org your self with some asm ? Or that you modified the dat file?

correct.

Quote:
you best send the code to support to have it checked

I will do that.

Thanks!
Back to top
View user's profile AIM Address
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Sep 10, 2020 9:55 pm    Post subject: Reply with quote

I forgot about several interrupts defined in include files. I've been able to eliminate all but one compile error. Possibly due to AVR-DOS and SD card includes.
Back to top
View user's profile AIM Address
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Sep 10, 2020 10:53 pm    Post subject: Reply with quote

All good now! Thanks for the info about the interrupts, Mark!
Back to top
View user's profile AIM Address
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Fri Sep 11, 2020 1:04 am    Post subject: Reply with quote

If one of the include files has an ISR in it (label: do stuff : return), does that have to be jumped over so that code execution won't start there?
Back to top
View user's profile AIM Address
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Sep 11, 2020 10:40 am    Post subject: Reply with quote

that depends on your program flow.
code should not walk into that code.

you can also rewrite as a sub :

Quote:
on int0 myisr

myisr:

return

would become :

sub myuser()

end sub


that should solve that.

_________________
Mark
Back to top
View user's profile Visit poster's website
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Apr 20, 2023 6:03 pm    Post subject: CONFIG SUBMODE=NEW and ON INTERRUPT Reply with quote

With Config submode=new, does the ON Interrupt statement need to come after the ISR?
Does the On Interrupt need a goto jump over?


example:

Sub Rx1_rcv_isr()
' Rx1 byte reception interrupt service routine (URXC1 ISR)

' some code

End Sub


On Urxc1 Rx1_rcv_isr ' byte received ISR
Back to top
View user's profile AIM Address
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Apr 20, 2023 7:14 pm    Post subject: Reply with quote

it does not matter where you put ON INT label/sub
this in contrast to normal subs and calling.

the normal way is that you either write the DECLARE or the implementation first, then the code that calls.
but since ON INT is handled different, you can put the ON INT before or after.

and there is no jump over needed.

_________________
Mark
Back to top
View user's profile Visit poster's website
jeremywilson

Bascom Member



Joined: 11 Jul 2011
Posts: 79
Location: United States

usa.gif
PostPosted: Thu Apr 20, 2023 9:19 pm    Post subject: Reply with quote

thanks!
Back to top
View user's profile AIM Address
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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