Interrupts + PWM + Constant I/O Update [NEWBIE] [C]

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

Hi,

I am working on a little bot, my first project, need help. I learned AVR in Assembly, have no experience of using C with AVR, but I have learned C in school(simple and not to an advanced level) but that too on a PC not a uC, AVR is my first uC, I am a NEWBIE. I want to program in C.

THE SCENARIO

I am using ATMega32, with all default settings. I have got 2 Motors, 2 sensors(active HIGH) these should remain OFF the line, I get HIGH when the sensor is ON THE LINE. Both motors have almost the same PWM, I have connected the sensor outputs to the INT0 and INT1 pins, need to use external interrupt and I intent to change the PWM (Phase Correct mode from Timer0 and Timer2) of motors, if the senor comes on line.

I have it on external interrupt, cause there are a few other sensors as well, which I will be constantly polling and updating some registers and outputting desired values.

THE PROBLEM

1. I need to setup interrupts on ANY LOGICAL CHANGE, how to do that.
2. How to call the Interrupt, need help with the ISR(); stuff... can't figure that out.
3. How to CHECK A PARTICULAR PIN for HIGH OR LOW INPUT in C.
4. How to CHANGE A PARTICULAR PIN to HIGH OR LOW OUTPUT in C.
5. I am sure I will be posting more problems SOON...

Please HELP ME.... many thanks in advance to those who will HELP me.....

What I actually need some WELL COMMENTED SAMPLE C CODE, I am using ATMEL AVR STUDIO with AVR GCC. I am a FAST and GOOD LEARNER.....

Regards,

Zaid Pirwani

Last Edited: Sun. Jun 13, 2010 - 05:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please HELP, I am desperate and need to have this done FAST....

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

Quote:
1. I need to setup interrupts on ANY LOGICAL CHANGE, how to do that.
Set the ISCxx bits in MCUCR to the proper value.
Quote:
2. How to call the Interrupt, need help with the ISR(); stuff... can't figure that out.
You don't call the interrupt, the AVR does. Just define the ISRs for the interrupts that you want, set the interrupt enable flag for that interrupt, and set the global interrupt flag.
Quote:
3. How to CHECK A PARTICULAR PIN for HIGH OR LOW INPUT in C.
4. How to CHANGE A PARTICULAR PIN to HIGH OR LOW OUTPUT in C.
Read the Programming 101 thread in the Tutorials forum.

Regards,
Steve A.

The Board helps those that help themselves.

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

Do you think you used a large enough font?
I could almost still read your post

Moderator

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

Quote:
Do you think you used a large enough font?
I could almost still read your post

That font was so big,
How big was it?
That font was so big I had to take my glasses off to read it!

(todays the worst joke ever award go's to....... ME

Self proclaimed Captain Link

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

BTW, is the AVR Simulator in AVR STUDIO reliable enough... cause I don't think it can SIMULATE the external Interrupts on ATMEGA32 when set as ANY LOGICAL CHANGE, as it is not giving me the EXPECTED RESULT and I am sure my code was correct.... I have WINAVR installed, but I don't know how to use it and hence am using AVR GCC compiler through AVR STUDIO....

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

clawson wrote:
Do you think you used a large enough font?
I could almost still read your post

Moderator

Well you had been of much help, though I also saw that after I pressed PUBLISH.....
:P

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

Quote:
and I am sure my code was correct....
And since you have not shown us a single line of that code, we have no way of verifying that it is indeed correct. And I am sure that functionality works in the simulator. So it is either your code or the way you are using the simulator.

Regards,
Steve A.

The Board helps those that help themselves.