View previous topic :: View next topic |
Author |
Message |
yyj679
Joined: 06 Apr 2015 Posts: 2
|
Posted: Thu Apr 16, 2015 1:57 pm Post subject: Help: About Mega328p use external interrupt PCINT |
|
|
To learn Mega328p PCINT use external interrupts, I write a test code, and try debugging simulation function that comes with BASCOM, but I have some problems, please guide:
After the program compiled directly above simulation only click button {PCINT0} in the “Interrupts page” of window in the “AVR Simulator”, Window Hardware simulation of the PD (similar LED) have corresponding results change, and click with the mouse regardless PB7, or click IB7, LED will not be changed, how to explain?
Thanks in advance.
Kind regards
(Sorry, my English is very poor)
Here is my code:
'$sim
$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 90
$swstack = 60
$framesize = 100
' 76543210
Ddrc = &B11111111
Portc = &B00000000
' 76543210
Ddrb = &B01111111
Portb = &B10000000
Iett_down Alias Pinb.7
On Pcint0 Isr_pcint7
Pcmsk0 = &B10000000
'Set Pcifr.0
' 76543210
Ddrd = &B11111111
Portd = &B00000001
Dirc Alias Portd.0
Speaker Alias Portd.7
Enable Pcint0
Enable Interrupts
Do
Speaker = Not Speaker
Waitms 1
Loop
End
'******************************************
Isr_pcint7:
If Iett_down = 0 Then
Dirc = Not Dirc
End If
Return
(BASCOM-AVR version : 2.0.7.8 )[/img] |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Thu Apr 16, 2015 2:53 pm Post subject: |
|
|
you use : Iett_down Alias Pinb.7
that means you need to change PINB register and not PORTB register. _________________ Mark |
|
Back to top |
|
|
yyj679
Joined: 06 Apr 2015 Posts: 2
|
Posted: Sun Apr 19, 2015 1:17 am Post subject: |
|
|
albertsm wrote: | you use : Iett_down Alias Pinb.7
that means you need to change PINB register and not PORTB register. |
Thanks for your reply
Have used in my code Ddrb = & B01111111 defines PB7 is PINB. 7
However, I still want to ask:
In "AVR Simulator", question 1: if only set IB7 status first, then click {PCINT0} button, program will accept PCINT7 interrupt response?
Question 2: if only change the status of IB7, AVR Simulator will not raise the interrupt response?
Thanks in advance.
Kind regards |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Tue Apr 21, 2015 9:58 am Post subject: |
|
|
the simulator needs the user to trigger the interrupt/event.
it will not automatic respond to pin changes. _________________ Mark |
|
Back to top |
|
|
|