View previous topic :: View next topic |
Author |
Message |
kartmanne
Joined: 02 Mar 2018 Posts: 28
|
Posted: Sun Jan 20, 2019 5:19 pm Post subject: Simulator: print# not executed |
|
|
HI,
I'm using a xmega128a1 and just want to use the BASCOM simulator, for the first time. So I had some questions, hope you can give some tips:
1. The Programm uses hardware-"com3" for output. But how can I get the outputs made with "print #1" in a terminal window?
2. print #1 will not be executed, means the simulator stops at this line.
EDIT: If I fire by clicking one of the enabled interrupts, the simulator executes these interrupts - but still hangs at the print#1.
Any idea?
THX
Manfred
(BASCOM-AVR version : 2.0.8.1 ) _________________ CU
Manfred |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Jan 20, 2019 7:47 pm Post subject: Re: Simulator: print# not executed |
|
|
kartmanne wrote: | Any idea? |
Sure, reduce your code to a minimum and post it. |
|
Back to top |
|
|
kartmanne
Joined: 02 Mar 2018 Posts: 28
|
Posted: Wed Jan 23, 2019 12:55 pm Post subject: |
|
|
HI,
ok - her is the much sa possible reduced code:
$regfile = "xm128a1def.dat" 'atxmega128a1 definitionsdatei
$lib "xmega.lib"
'BASCOM 2079: include the following lib and code, the routines will be replaced since they are a workaround
$external _xmegafix_clear
$external _xmegafix_rol_r1014
$crystal = 32000000
$hwstack = 640
$swstack = 640
$framesize = 4096
Config Osc = Enabled , 32mhzosc = Enabled , 32khzosc = Enabled ' enable 32 MHz internal , interner 32khzOSC ein , calibration auf 32khzint
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 ' osc-source and prescaler to ensure 32MHz
$loadersize = &H10000
'***variablen,konstanten
Dim I As Byte
'***interrupts
Config Priority = Roundrobin , Vector = Application , Lo = Enabled
'grsadkw abfrage
Config Tcc1 = Normal , Prescale = 8
Tcc1_per = 40
On Tcc1_ovf Isr_poll_gradkw
Enable Tcc1_ovf , Lo
'***uart
Config Portd.3 = Output 'TX UARTc0
Config Portd.2 = Input 'RX uartc0
Config Com3 = 57600 , Mode = 0 , Parity = None , Stopbits = 2 , Databits = 8 'com einstellen
Open "com3:" For Binary As #1 'com3 öffnen
Enable Interrupts
Print #1 , "***"
'*** Hauptschleife ***
Do
Loop
Close #1
End
'/*** hauptschleife ***
Isr_poll_gradkw:
Incr I
Print #1 , I
Return
The PC is a win-XP-SP3-machine running @1GHz AMD-Athlon, 2GB Ram. (I know, it's vintage, but for me fast enough for coding...) _________________ CU
Manfred |
|
Back to top |
|
|
kartmanne
Joined: 02 Mar 2018 Posts: 28
|
Posted: Wed Jan 23, 2019 1:00 pm Post subject: |
|
|
HI,
the simulator stops at the first Print #1 , "***" .
After fireing Tcc1_ovf manually, the ISR is beeing executed. Var I is being incremented but the sim stops again at Print #1 , I, no further ISR could be executed.
I guess, it depends on the com-port. But no idea why and how to solve or work around... _________________ CU
Manfred |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jan 23, 2019 8:19 pm Post subject: |
|
|
Your code simulates correctly for com1 and com2, as furthermore in simulator you do only find tabs for UART0 = com1 and UART1 = com2, the likelihood is pretty high that the simulator can not handle com3, which would be UART2.
As there is no terminal emulator window for UART2 available, trying to simulate without output is moot anyway, what result do you expect?
The point the simulator gets stuck at the Print-commands is not correct imho, ignore/run over the command should happen.
From simulation in AVR-Studio the code itself looks ok and seems to do what it should.
Do you use an older version?
The following should not be required in actual versions:
Code: | $lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014 |
|
|
Back to top |
|
|
kartmanne
Joined: 02 Mar 2018 Posts: 28
|
Posted: Thu Jan 24, 2019 3:27 pm Post subject: |
|
|
HI,
com3 was chosen because of the hardware, the pcb is very small and there are many components placed. com1 or com2 need more complex routing. Today the pins of com1 and2 are in use for other functions.
I could use a sw-com for other ports (to redirect to com1 or com2), but the whole system runs at nearly 90% of max performance, so less head room is too risky. Additionally, I do not know, if BASCOM uses a timer for sw-com. All timers are in use for other functions in the current full code.
In general this quoted code does not show any useful info on the terminal, but for further and more complex code I want to see the output until the hardware will be available. If available I will use hardware com-ports and hyperterm.
I don't know since what BASCOM version the mega work around is obsolete. I use 2081, now. I left it, because if not required BASCOM will ignore anyway, I think. But, you're right, obsolete code shall be deleted.
THX for your comments. _________________ CU
Manfred |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Jan 24, 2019 3:33 pm Post subject: |
|
|
i need to check it, but i think the simulator does not support all com ports. I will let you know later but for now it is safe to assume that only the first com port is supported by the sim. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Jan 24, 2019 5:15 pm Post subject: |
|
|
kartmanne wrote: | com3 was chosen because of the hardware, the pcb is very small and there are many components placed. com1 or com2 need more complex routing. |
You can use this as workaround:
Code: | $regfile = "xm128a1def.dat" 'atxmega128a1 definitionsdatei
$crystal = 32000000
$hwstack = 640
$swstack = 640
$framesize = 4096
$sim ' removes waits
' ...
#IF _SIM = 1
Config Com1 = 57600 , Mode = 0 , Parity = None , Stopbits = 2 , Databits = 8
Open "com1:" For Binary As #1
Config PORTC.3 = INPUT
#ELSE
Config Com3 = 57600 , Mode = 0 , Parity = None , Stopbits = 2 , Databits = 8 'com einstellen
Open "com3:" For Binary As #1 'com3 öffnen
#ENDIF
' ... |
This conditional compilation lets you see your output in UART0 tab, to compile for the controller, you have to remove $sim.
Quote: | Additionally, I do not know, if BASCOM uses a timer for sw-com. |
No timer is used.
Quote: | I want to see the output until the hardware will be available. |
You will find out that the simulator is good for certain code, while for code where you need real life execution it shows its limits.
For such cases I set up a small test environment, where for example calculations can be checked for correctness, which are otherwise hard to test in real hardware and real speed. |
|
Back to top |
|
|
kartmanne
Joined: 02 Mar 2018 Posts: 28
|
Posted: Thu Jan 24, 2019 7:33 pm Post subject: |
|
|
MWS wrote: |
$sim ' removes waits
' ...
#IF _SIM = 1
Config Com1 = 57600 , Mode = 0 , Parity = None , Stopbits = 2 , Databits = 8
Open "com1:" For Binary As #1
Config PORTC.3 = INPUT
#ELSE
Config Com3 = 57600 , Mode = 0 , Parity = None , Stopbits = 2 , Databits = 8 'com einstellen
Open "com3:" For Binary As #1 'com3 öffnen
#ENDIF
' ...[/code]speed. |
ah, good idea
I know, that for real controller speed the simulator may not be fast enough or shows other limits. Mostly I want to see, that mathmatics are set correct and variables are being output correctly. So I can be sure, one side of the communication is free of logic bugs. The whole communication has to be tested under real controller performance. Using the sim with all interrupts couldn't be done because the interrupt-triggers couldn't be set up by the sim. This can only be done and watched running the controller.
Thx for help _________________ CU
Manfred |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Feb 01, 2019 10:40 am Post subject: |
|
|
I checked it and indeed there was only support for usart0 and 1. I added support for 2 and 3.
So check it out in the next version. _________________ Mark |
|
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
|
|