Newbie help with Interrupts and Bascom

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've got an ATTiny13V on a breadboard with LEDs on Portb.3 and Portb.4. I've also got Portb.0 (which should be PCINT0 according to the data sheet pulled up to 5V through a 10K resistor and hooked to a pushbutton to ground.

$regfile = "attiny13.dat"
$crystal = 9600000

Config Portb.3 = Output
Config Portb.4 = Output
Config Portb.0 = Input

Do
   Debounce Pinb.0 , 0 , Switch_led , Sub
   Toggle Portb.3
   Waitms 50
Loop

Switch_led:
   Toggle Portb.4
Return

End

I can poll Portb.0 to see when the switch is pressed, but this runs into problems when the period of the other LED flash gets longer. I'd like to enable interrupts and experiment with an ISR to handle the button push.

Can someone give me a little handholding on how to do this using Bascom? Once I get it running under Bascom, I'll try it in C using AVR Studio.

Cheers,

Tom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
Just a bit of advice: go to the MCS website and enter the Bascom-AVR Forum and they will help you. Usually you will always get help from Luciano, DToolan, and Ian Dobson. All are experts with Bascom and the AVR. I have never asked Luciano something he could not answer.

As for the ISR, you have many commands at your disposal. First you need ENABLE INTERRUPTS command; then ENABLE INT0 to set the interrupt option on your port; then ON INTERRUPT which will send the code to your ISR.

Trust me, if you want BASCOM help, go to the MCS site:
www.mcselec.com

Take care, john :D

Just some guy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, John. On my way there now.

Cheers,

Tom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello again,
I forgot that I had bookmarked this link on interrupts. Hope it helps.

http://www.qsl.net/pa3ckr/bascom...

Just some guy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, John. This is what I've got right now after visiting MCSs site and searching the interrupt threads:

$regfile = "attiny13.dat"
$crystal = 9600000

Led1 Alias Portb.3
Led2 Alias Portb.4
Button Alias Portb.0

Config Led1 = Output
Config Led2 = Output
Config Button = Input

Button = 1  'set pullup resistor
Set Pcmsk.pcint0
Set Gimsk.pcie

On Pcint0 Pcint0_isr
Enable Interrupts

Do
   Toggle Led1
   Waitms 40
Loop

Pcint0_isr:
   If Pinb.0 = 0 Then
      Waitms 20
      If Pinb.0 = 0 Then
         Toggle Led2
      End If
   End If
Return

End

Now to do a little more playing to adjust the wait time whenever a interrupt occurs to prevent the longer cycle on LED1. Then to do the same exercise using a timer on LED1 and polling the pushbutton in an endless main loop.

Cheers,

Tom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need to breadboard something similar and learn more about 'interrupts' myself. Also, I do not know any "C" at all but, it looks pretty powerful. I wish I had more time to devote to learning a new language right now.
Take care, John

Just some guy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am a newbie, I have an android project from the input text to be displayed on the dot matrix via a wifi connection, I've managed to send it but when I want to send a text again, can not be displayed, I've tried changing the algorithm then the text can be re-sent and displayed on the dot matrix but still, when I send a text again still failed .. please help me interrupt what should I use? or is there any other way? I use a basic programming language with Bascom avr. thank you ...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

Perhaps a Moderator will move this to a new Thread.

You need to describe better your hardware, what does work, and what does not work. Send a message from what to what? Where is the android in the system? Where is the micro in the system? What micro? What PCB? Is the micro connected to the wifi? If so, how? What parts of the system work?

JC