View previous topic :: View next topic |
Author |
Message |
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Fri Aug 17, 2018 8:32 am Post subject: Help who can, the problem with interrupts XMEGA128A1U |
|
|
Hello everybody!
Help who can, the problem with interrupts XMEGA128A1U - See the picture…
The processor prints the text on the display, using the font from the parallel flash EEPROM.
At certain points in time, the timer interrupts.
The new value is loaded in the period register, and the bit in the port is also set.
This activates the INT0 interrupt.
After exiting the timer interrupt, a jump to the INT0 (LO) interrupt occurs - At this point, randomly, the CPU hangs, when a large amount of text is output.
When I disable INT0, the timer does not cause the CPU to hang.
At the beginning of the INT0 subroutine, the LED turns on to check the code execution.
When the processor hangs(the printing of the text stops and does not react at all), the LED does not turn on - the subroutine for INT0 is not started.
The program is large, what its functions are needed for analysis I'll post.
Thanks,
Ruslan
(BASCOM-AVR version : 2.0.8.1 ) |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Fri Aug 17, 2018 9:34 am Post subject: |
|
|
Hi,
Without seeing the rest of the code, it's hard to say what's wrong. But could it be that your doing "alot of work" in you interrupt handler? If yes, that could be your problem.
Interrupt handlers should be kept as simple as possible (just set a flag, and the main application checks this flag and does something if it's set).
Also are your stacks large enough (HWSTACK,HWSTACK,FRAME).
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Fri Aug 17, 2018 9:49 am Post subject: |
|
|
Thanks, Ian Dobson for reply!
Added description of initialization.
Can there be restrictions on calling interrupts and working with EBI?
Regards,
Ruslan. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sat Aug 18, 2018 12:57 am Post subject: |
|
|
I am having the same problem intermittently the m664p hangs it can run for a few days or just a few hours
Tried turning off each of the interrupts int0 , int2
Turned off all interrupts
Gave it plenty of stack space 300, 300 ,300 so not that
Just can not find out why
So will follow this discussion closely
Regards Paul |
|
Back to top |
|
|
JC
Joined: 15 Dec 2007 Posts: 584 Location: Cleveland, OH
|
Posted: Sat Aug 18, 2018 3:16 am Post subject: |
|
|
I still recall one bug that was very hard to track down.
I usually debug with an LED and sometimes an LCD, along with an O'scope.
After weeks of trying to find an intermittent bug I purchased a decent digital O'scope, which has now essentially replaced my old analog scope.
The program could crash in a few minutes, or sometimes run for several days before it crashed.
As the program was very long, and was close to filling the chip, I reused some variables for different parts of the code.
It finally turned out that if one specific ISR, (of many), ran during one specific line of code, (of thousands), then a variable was trashed and the code crashed.
It was a relief to finally find the exact cause for the bug.
Another bug that took me a long while to track down was in a different program where most of the program ran from within the ISR ( s ), with very little in the Main Loop.
I had a Floating Point calculating running in the ISR, (generally a bad thing), but not a problem as there was plenty of time for it to execute.
The problem was I had not yet learned about the SAVE ALL option for ISRs, and a register or two was getting trashed within the ISR.
Once I learned about that the program ran fine.
You already mentioned that you have large Stacks allocated, that is good as it can also cause some interesting bugs.
Good luck with your debugging.
JC |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Sat Aug 18, 2018 2:31 pm Post subject: |
|
|
The variables in the text output routine were originally local, I made these variables global, but that did not help.
I tried to use the library stackcheck.lib and display _hw_lowest, _fw_highest, _sw_lowest.
And also tried STCHECK, ERROR is always 0
While the processor does not hang any problems is not observed.
Output to the pins and connected the oscilloscope, channel 1 - INT0 pin, channel 2 - TEST pin:
we get into the ISR of the TIMER, the SET TEST pin
we get into the ISR of the INT0, the RESET TEST pin(at the very beginning of the subroutine).
If the processor hangs, on the oscilloscope there remains on both channels a step 0>1
What says that the hang occurred at the time of the ISR INT0 call.
Who knows how the interrupt processing happens?
If an interrupt occurs at a higher level, a low level interrupt is triggered at this time.
And after exiting the high-level interrupt:
a - the program returns to the interrupt(HI) address of the program and then goes to the interruption(LO) task.
b - the interruption is immediately executed. What does this write to the stack?
p.s. I'm thinking about buying AVR DRAGON...
Debugging Interfaces
• JTAG (JTAG)
• debugWIRE (dW)
• PDI (PDI)
• aWire (aWire)
Quote: | Who knows how the interrupt processing happens?
If an interrupt occurs at a higher level, a low level interrupt is triggered at this time.
And after exiting the high-level interrupt:
a - the program returns to the interrupt(HI) address of the program and then goes to the interruption(LO) task.
b - the interruption is immediately executed. What does this write to the stack? |
Checked in the simulator AVR STUDIO - works on option a
Last edited by pyclan on Mon Aug 20, 2018 12:54 pm; edited 1 time in total |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Mon Aug 20, 2018 10:57 am Post subject: |
|
|
without the code in the ISR it is hard to determine.
But i see : On Tcd1_ovf Module3_timer
Which means only main regs are saved. _________________ Mark |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Mon Aug 20, 2018 11:36 am Post subject: |
|
|
Hi Mark!
I do not run the other timers yet.
I'm still working only with - On Tcc1_ovf Module1_timer Saveall |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Mon Aug 20, 2018 11:56 am Post subject: |
|
|
Explanation of the code:
In the main loop (all initialize and ready to work CYCLE_II.inc) the origin of the touch screen poll.
We are interested in the START(line 728)
global_module = cnst_1
Running - Gosub Start_cycle
line 1606:
Tcc1_per = Param_co1(cnst_1)
Tcc1_cnt = Cnst_0
Start Tcc1
Start Tcc0
Next comes the process described by me in the first post. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Mon Aug 20, 2018 1:17 pm Post subject: |
|
|
i advise to check out $frameprotect since you call user subs in your ISRs _________________ Mark |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Mon Aug 20, 2018 1:58 pm Post subject: |
|
|
Yes Mark, I included this option ($frameprotect=1), but it does not affect the behavior of the program.
Simplified the code:
CYCLE_II.inc
Code: | Enable Interrupts
Gosub Display_init
En_amp = Cnst_sound_on '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Gosub Exit_sound
Call Read_touch
Tcc1_per = 200
Tcc1_cnt = Cnst_0
Start Tcc1
Start Tcc0
Set Lcd_led
Lcd_text = "23425089375890278953702983745UI2HVKJNKJVCSXKH"
Do
For Tmp_word = Cnst_1 To 457 Step 24
Call Ssd1963_txt(lcd_text , Cnst_1 , Tmp_word , Red , Black , Arial24_b , Cnst_align_off) 'Lcds_text,X,Y,FONT_COLOR,BACK_COLOR,FONT,ALIGN
Next
For Tmp_word = Cnst_1 To 457 Step 24
Call Ssd1963_txt(lcd_text , Cnst_1 , Tmp_word , White , Black , Arial24_b , Cnst_align_off) 'Lcds_text,X,Y,FONT_COLOR,BACK_COLOR,FONT,ALIGN
Next
Loop |
Control.inc
Code: |
Module1_timer:
'*******************************************************************************
Set Pow_fail
Sound Beep , 3 , 500
Reset Pow_fail
Set Int_send
Return
Interrupt_send:
'*******************************************************************************
Reset Pow_fail
Stop Tcc0
Co_int_copy = Co_int
Co_int = Cnst_0
Bitwait Dma_ch0_ctrla.7 , Reset 'Sometimes graphics are output, but this does not affect the appearance of an error
Start Tcc0
Reset Int_send
Return
|
|
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Tue Aug 21, 2018 3:03 pm Post subject: |
|
|
Hello everybody!
Problem found!
Mark, why not save and clear the rest of the RAMP registers?
At least with the option SAVEALL.
Thank you all for your help!
Continue Working... |
|
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
|
|