input pin interrupt self triggering

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

I wrote the following code that runs on the ATmega4809 development board and the output constantly pulses at 89KHz regardless of whether there is an input or not. I can't work out where this frequency is picked up from and why it won't follow the frequency of the sig gen when connected:

 

#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>

ISR( PORTA_PORT_vect){
	PORTD.OUTSET = ( 0x1 << 4 );
	PORTD.OUTCLR = ( 0x1 << 4 );
}

int main(void)
{	
	// I/O setup	
	PORTA.DIRCLR = 0x1 << 0; // make PA0 INPUT
	PORTD.DIRSET = 0x1 << 4; // make PA1 OUTPUT

	PORTA.PIN0CTRL = (0x1 << 0) | (0x1 << 3); // Setup PA0 with interrupt enabled on both edges and pull up enabled
	
	sei(); // Turn global interrupts on.
		
    /* Application code */
    while (1) 
    {
		
	 }
}

 

This topic has a solution.
Last Edited: Tue. Nov 6, 2018 - 03:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

My guess is the pull up is not enable as you think it is.

 

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

The pull up should not make much difference? I'm driving with a 0-5V signal

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

SparkyLabs wrote:
The pull up should not make much difference? I'm driving with a 0-5V signal

That was not stated in the OP.   Watchdog perhaps? 

 

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

I thought WDT too but you can't make it go that fast can you?

 

1 / 89kHz  = 11us

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

Don't you need to clear the interrupt flag inside the ISR before exiting?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

is the watchdog enabled by default?

 

If I connect the input to ground and power it up nothing comes out. As soon as I disconnect it the output starts up and no matter what I do it does not change.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Quote:

Interrupt flags are not automatically cleared after the interrupt is executed. The respective INTFLAGS register descriptions provide information on how to clear specific flags.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Got it to work :) Thank you for your help.

 

Now to get the PWM decode on a TCB to work

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

SparkyLabs wrote:

Got it to work :) Thank you for your help.

 

Good, but how? For the benefit of anyone else who has the same problem and finds this topic how did you solve it?

 

If it was a post above then use the 'mark as solution' button.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

resetting the interrupt did it. But I am still confused as to how it was pulsing at all.