PORTC and JTAG disable/enable

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

Hello!

I wan't my PORTC to be an output to pull on/off my 7-segment LED display. But the problem is that my PC0,PC1 and PC6 are working properly but other pins on PORTC are always down. Is this a problem of JTAG, do I need to disable it in code? I run my program on ISIS Proteus and there is working all ok, on Atmega is not.

P.S. sorry on crappy english :)

Thanks in advance!

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

Quote:

Is this a problem of JTAG, do I need to disable it in code?

Yes and Yes. If you don't have a JTAG interface then just disable the JTAGEN fuse (it's enabled by default when the AVR is delivered). If you do have a JTAG interface you may want to use at some stage then in your software just do:

int main(void) {
  MCUCSR = (1<<JTD);
  MCUCSR = (1<<JTD);
// rest of program

Make sure this is built with optimisation switched on (as the double write has to be done within 4 cycles).

As this has little specifically to do with AVR Studio 4 then I'll move this thread to AVR forum.

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

Quote:
Make sure this is built with optimisation switched on (as the double write has to be done within 4 cycles).

What do you mean by this?

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

Quote:

What do you mean by this?

If you still have a question after reading about JTD in the datasheet get back to me.

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

OK! I will read about that. We'll stay in touch :)

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

Here it is! I disabled MCUCSR in code, I guess now it will work. Tommorow I will try it on my ATmega and I hope will work like a Swiss clock :)

Thanks clawson!

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

Now pins are all working, but now when my 7-segment LED display comes to number 7 it freezes, it pass 9 and 8 and on 7 it freezes. What is the problem now? I only put in code two lines of MCUCSR = (1<<JTD); do I have to put something else???

Please help!

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

Post the program. Dont forget to use the code tag.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#define F_CPU 1000000UL

#include 
#include 
#include 

#define MIN_BROJ_VOZILA 10
#define BROJ_PRELJEVA_TIMERA 1

volatile int a = 1;
volatile int b = 1;
volatile int interrupt_counter0 = 0;
volatile int interrupt_counter1 = 0;
volatile int count = 0;
volatile int timer_overflow = BROJ_PRELJEVA_TIMERA;


void usporedi(int n, int m) {
	if(n>m) {
		a = 2;
		b = 1;
		}
	else if(n=MIN_BROJ_VOZILA)
	   	{	
   	
			cli();
			usporedi(interrupt_counter0,interrupt_counter1);  
			interrupt_counter0 = 0;
			interrupt_counter1 = 0;
			//_delay_ms(1000);	
			count=0;
			timer_overflow = BROJ_PRELJEVA_TIMERA;
	   		// Djelitelj = FCPU/256
	   		TCCR0|=(1<<CS02);

   		}

	   	else {

	   		count=0;
			timer_overflow = BROJ_PRELJEVA_TIMERA;
	   		// Djelitelj = FCPU/1024
	   		TCCR0|=(1<<CS02)|(1<<CS00);
	
			  }
	}	
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a question. I use timer counter 0 and one of my output pin is PB0 which is use for T0. My 7-segment display is turned on/off on that pin, is there any chance that could be the source of problem???