Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Help: About Mega328p use external interrupt PCINT

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

Bascom Member



Joined: 06 Apr 2015
Posts: 2

PostPosted: Thu Apr 16, 2015 1:57 pm    Post subject: Help: About Mega328p use external interrupt PCINT Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4970
Location: Holland

blank.gif
PostPosted: Thu Apr 16, 2015 2:53 pm    Post subject: Reply with quote

you use : Iett_down Alias Pinb.7
that means you need to change PINB register and not PORTB register.

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

Bascom Member



Joined: 06 Apr 2015
Posts: 2

PostPosted: Sun Apr 19, 2015 1:17 am    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4970
Location: Holland

blank.gif
PostPosted: Tue Apr 21, 2015 9:58 am    Post subject: Reply with quote

the simulator needs the user to trigger the interrupt/event.
it will not automatic respond to pin changes.

_________________
Mark
Back to top
View user's profile Visit poster's website
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