Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Interrupt management

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various
View previous topic :: View next topic  
Author Message
jackfrost

Bascom Member



Joined: 05 Sep 2006
Posts: 5
Location: Tucson, Arizona

usa.gif
PostPosted: Thu Feb 16, 2023 1:45 am    Post subject: Interrupt management Reply with quote

The following code compiles and run ON THE SIMULATOR
This code does not RUN IN THE HARDWRE.ANY SUGGESTIONS?

SEE ATTACHED FILE[/code][/u]
Back to top
View user's profile Visit poster's website
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Thu Feb 16, 2023 6:00 am    Post subject: Reply with quote

Maybe

Config Int0?

E
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Thu Feb 16, 2023 8:01 am    Post subject: Reply with quote

If PORTD.1 (INT0) is not pulled up to VCC by some resistor eg.10K then you should atleast enable internall pullup by setting "PORTD.1 = 1"

BTW. This uC is shipped with CKDIV8 enabled in the factory so its freq is 1MHz unless you disable this divider in the Fuses.

_________________
Check B-Flash -my MCS bootloader app for Android
Back to top
View user's profile Visit poster's website
jackfrost

Bascom Member



Joined: 05 Sep 2006
Posts: 5
Location: Tucson, Arizona

usa.gif
PostPosted: Fri Feb 17, 2023 12:35 am    Post subject: Reply with quote

Thanks for taking time to read and reply! I’m in over my head when it comes to coding a uC. If I had board space designing a circuit using CMOS logic would be straight forward.
I see in the mega165 datasheet some mention of the status byte changes when an interrupt occurs and on completion of the subroutine. I don’t see any change when simulating but I’m not sure I’m looking in the right place. In the datasheet it’s assumed that the coding is for a C compiler NOT BASCOM…
When this problem is resolved I’ll make a point out of posting how it was fixed…
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Fri Feb 17, 2023 10:22 am    Post subject: Reply with quote

to be clear : int0 for the atmega165 64 pin package is at pin 26 (pind.1)

there are simple tests to see if a pin works :
Code:
config pind.1 as input
portd.1=1 'activate internal pull up

config portc=output

do
  if pind.1=0 then
     portc=0
  else
     portc=255
  end if
 loop


then apply signal using a wire ot whatever and port should follow this signal.
that would be one of the first tests.
 


then to test int registers :

Code:
config portc=output
enable int0

do
  if eifr.0=1 then
     portc=255 'or do some led
     eifr=1 'reset the flag !!!
  end if  
loop
 


notice that this sample has no interrupt label, it just test if the flag becomes set.
in this case that is EIFR register bit 0.
this flag is reset to 0 when an interrupt routine is executed. but we did not provide this so we must manual reset this flag by writing a 1 to it.

when you also provide a label to be called using ON INT0 SOMELABEL that label will be called.

the simulator will sim just enough to get the code going. it is not intended and is not a total representative image for the internal processor.

_________________
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 -> Various 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