Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Weirdness on Butterfly...

Weirdness on Butterfly...

2005-01-13 by Mike Murphree

Ran into a weird problem this week while modifying the AVR Butterfly 
code for my own application.
On the Butterfly, the pins for Port B bits 4,6, and 7, plus Port E bits 
2 and 3 are used for the joystick.  I am using these pins for my own 
application and am only using the LCD driver code, the USART code, and 
the oscillator calibration code out of the original application.  The 
weird part was that all of these pins were set to inputs and I had 
pullups enabled (confirmed in Studio), but both in my application and 
in Studio's I/O panel, these bits in Port E were being read as zeroes.  
I also confirmed with a DVM that these pins were at a high level.

I got my project working by reassigning the pins in Port E to Port B, 
but I'm at a loss as to what was happening with the Port E pins.  I 
checked with the original source and the board worked fine then.

Any ideas?

Mike

Re: Weirdness on Butterfly...

2006-04-12 by granz_consult

Mike,

I am also having wierdness with the Butterfly's Port E.  In trying to
use the onboard joystick, I am showing continuous action of both left
and right joystick (the two Port E pins).  I have been sucessful in
reading the Port B pins (up, Down and Center), but have not been able
to read the Port E pins at all.

I've tried writing the DDRE pins, then activating the pull-up resistor
by writing to PortE pins and then reading from the PinE pins to test
for left/right action, but am always showing both being true.

Have you had any answers or any sucess on your own in solving this?

Thanks,

Art

--- In AVR-Chat@yahoogroups.com, Mike Murphree <mike@...> wrote:
Show quoted textHide quoted text
>
> 
> Ran into a weird problem this week while modifying the AVR Butterfly 
> code for my own application.
> On the Butterfly, the pins for Port B bits 4,6, and 7, plus Port E bits 
> 2 and 3 are used for the joystick.  I am using these pins for my own 
> application and am only using the LCD driver code, the USART code, and 
> the oscillator calibration code out of the original application.  The 
> weird part was that all of these pins were set to inputs and I had 
> pullups enabled (confirmed in Studio), but both in my application and 
> in Studio's I/O panel, these bits in Port E were being read as zeroes.  
> I also confirmed with a DVM that these pins were at a high level.
> 
> I got my project working by reassigning the pins in Port E to Port B, 
> but I'm at a loss as to what was happening with the Port E pins.  I 
> checked with the original source and the board worked fine then.
> 
> Any ideas?
> 
> Mike
>

Re: Weirdness on Butterfly...

2006-04-12 by kernels_nz

Hi Guys,

I have not worked with the butterfly myself and to make things even
worse, I dont even know what type of up it's got on it. But from the
conversation, the only thing that you might want to have a look at is
to make sure that JTAG is disabled (in the fuse bits). Otherwise, the
JTAG function overrides the normal port function.

Cheers
Hein B
Auckland
New Zealand.

--- In AVR-Chat@yahoogroups.com, "granz_consult" <granz_consult@...>
wrote:
>
> Mike,
> 
> I am also having wierdness with the Butterfly's Port E.  In trying to
> use the onboard joystick, I am showing continuous action of both left
> and right joystick (the two Port E pins).  I have been sucessful in
> reading the Port B pins (up, Down and Center), but have not been able
> to read the Port E pins at all.
> 
> I've tried writing the DDRE pins, then activating the pull-up resistor
> by writing to PortE pins and then reading from the PinE pins to test
> for left/right action, but am always showing both being true.
> 
> Have you had any answers or any sucess on your own in solving this?
> 
> Thanks,
> 
> Art
> 
> --- In AVR-Chat@yahoogroups.com, Mike Murphree <mike@> wrote:
> >
> > 
> > Ran into a weird problem this week while modifying the AVR Butterfly 
> > code for my own application.
> > On the Butterfly, the pins for Port B bits 4,6, and 7, plus Port E
bits 
> > 2 and 3 are used for the joystick.  I am using these pins for my own 
> > application and am only using the LCD driver code, the USART code,
and 
> > the oscillator calibration code out of the original application.  The 
> > weird part was that all of these pins were set to inputs and I had 
> > pullups enabled (confirmed in Studio), but both in my application and 
> > in Studio's I/O panel, these bits in Port E were being read as
zeroes.  
Show quoted textHide quoted text
> > I also confirmed with a DVM that these pins were at a high level.
> > 
> > I got my project working by reassigning the pins in Port E to Port B, 
> > but I'm at a loss as to what was happening with the Port E pins.  I 
> > checked with the original source and the board worked fine then.
> > 
> > Any ideas?
> > 
> > Mike
> >
>

RE: [AVR-Chat] Re: Weirdness on Butterfly...

2006-04-13 by Cat C

I have another similar problem with my GCC ported butterfly:
I need 4 output pins to eventually control a stepper motor, but for now I'm 
playing just with LEDs.
So first I tried to use PORTB0-3, but only 0, 1 and 2 went HI, and even 
those, not as I expected (not one at a time).
Then I tried PORTF4-7 (this is the code below, exactly as it was for portB, 
just F instead of B).
Almost same thing, except on some outputs the LED is dim when on (looks OK 
with voltmeter) and also not one by one.
I'm pretty sure there's something wrong with my code, or maybe choosing the 
port?
Most of the GCC ported code is still in there, LCD, interrupts (bootloader 
is gone), I just replaced the name tag with my own "stepper code" that for 
now should just cycle through the pins as I move the joystick.
I do get 1, 2, 4, 8 on the LCD... what's wrong?

Thanks,

Cat
char StepperRun(char cLastKey)
{
	DDRF|= (1<<DDF4) | (1<<DDF5) | (1<<DDF6) | (1<<DDF7);

	cbiBF(PORTF,PF4);cbiBF(PORTF,PF6);cbiBF(PORTF,PF5);cbiBF(PORTF,PF7);//make 
them '0'
    LCD_puts_f(PSTR("      "), 1);		//Clear LCD

	while (cLastKey != KEY_PREV)
	{
	if (cLastKey == KEY_PLUS)
	{
		if (iPort_0_3 == 1)
		{
			iPort_0_3 = 2;
			cbiBF(PORTF,PF4);
			sbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
		else if (iPort_0_3 == 2)
		{
			iPort_0_3 = 4;
			cbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			sbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
		else if (iPort_0_3 == 4)
		{
			iPort_0_3 = 8;
			cbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			sbiBF(PORTF,PF7);
		}
		else 		//If it's 8 or anything else
		{
			iPort_0_3 = 1;
			sbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
	LCD_putc(0, '0'+iPort_0_3);	//Put Last Value
	LCD_UpdateRequired(TRUE, 0);
	}
	if (cLastKey == KEY_MINUS)
	{
		if (iPort_0_3 == 8)
		{
			iPort_0_3 = 4;
			cbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			sbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
		else if (iPort_0_3 == 4)
		{
			iPort_0_3 = 2;
			cbiBF(PORTF,PF4);
			sbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
		else if (iPort_0_3 == 2)
		{
			iPort_0_3 = 1;
			sbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			cbiBF(PORTF,PF7);
		}
		else 		//If it's 1 or anything else
		{
			iPort_0_3 = 8;
			cbiBF(PORTF,PF4);
			cbiBF(PORTF,PF6);
			cbiBF(PORTF,PF5);
			sbiBF(PORTF,PF7);
		}
	LCD_putc(0, '0'+iPort_0_3);	//Put Last Value
	LCD_UpdateRequired(TRUE, 0);
	}
	LCD_putc(0, '0'+ iPort_0_3);
	LCD_UpdateRequired(TRUE, 0);
	cLastKey = getkey();
	}
	if (cLastKey == KEY_PREV)
	{
	cbiBF(PORTF,PF4);cbiBF(PORTF,PF6);cbiBF(PORTF,PF5);cbiBF(PORTF,PF7);//make 
them '0'
		return ST_STEPPER;
	}

return ST_STEPPER_RUN;
}

Re: Weirdness on Butterfly Joystick

2006-04-13 by ufo2joe

Maybe this will help. It's a routine that reads all four directions 
of the Joystick. Only set-up is writing 255 to the ports first.

;----------------<SNIP>----------------------------------------

 		OUT	PORTB,FF
		OUT	PORTE,FF
	    
;--------------------------------------------------------------;
; CRICKET: BOOT SENSORY LOOP: CHECK JOYSTICK & UART THEN SLEEP ;
;--------------------------------------------------------------;
            STS     TCCR1B,FIVE  ;PRESCALE /1024
            STS     TCNT1L,ZERO  ;START AT ZERO
            STS     TCNT1H,ZERO
BOOT_LOOP:  CLR     TMP
            SBIS    PINB,6       ;JOYSTICK UP
	     RJMP   START_8MHZ    	
            SBIS    PINB,7       ;JOYSTICK DOWN
             RJMP   START_2MHZ            
            SBIS    PINE,2       ;JOYSTICK LEFT
             RJMP   START_4MHZ
            SBIS    PINE,3       ;JOYSTICK RIGHT
             RJMP   START_1MHZ	

            LDS     TMP,TCNT1L   ;CHECK CLOCK
            LDS     TMP,TCNT1H
            CPI     TMP,255
             BREQ   GO_SLEEP

  	    LDS	    TMP1,UCSR0A	 ;CHECK UART
            SBRS    TMP1,RXC
             RJMP   BOOT_LOOP    ;NO UART THEN LOOP

;-------------------------------------------------------

--- In AVR-Chat@yahoogroups.com, "granz_consult" <granz_consult@...> 
wrote:
>
> Mike,
> 
> I am also having wierdness with the Butterfly's Port E.  In trying 
to
> use the onboard joystick, I am showing continuous action of both 
left
> and right joystick (the two Port E pins).  I have been sucessful in
> reading the Port B pins (up, Down and Center), but have not been 
able
> to read the Port E pins at all.
> 
> I've tried writing the DDRE pins, then activating the pull-up 
resistor
> by writing to PortE pins and then reading from the PinE pins to 
test
> for left/right action, but am always showing both being true.
> 
> Have you had any answers or any sucess on your own in solving this?
> 
> Thanks,
> 
> Art
> 
> --- In AVR-Chat@yahoogroups.com, Mike Murphree <mike@> wrote:
> >
> > 
> > Ran into a weird problem this week while modifying the AVR 
Butterfly 
> > code for my own application.
> > On the Butterfly, the pins for Port B bits 4,6, and 7, plus Port 
E bits 
> > 2 and 3 are used for the joystick.  I am using these pins for my 
own 
> > application and am only using the LCD driver code, the USART 
code, and 
> > the oscillator calibration code out of the original 
application.  The 
> > weird part was that all of these pins were set to inputs and I 
had 
> > pullups enabled (confirmed in Studio), but both in my 
application and 
> > in Studio's I/O panel, these bits in Port E were being read as 
zeroes.  
> > I also confirmed with a DVM that these pins were at a high level.
> > 
> > I got my project working by reassigning the pins in Port E to 
Port B, 
> > but I'm at a loss as to what was happening with the Port E 
pins.  I 
Show quoted textHide quoted text
> > checked with the original source and the board worked fine then.
> > 
> > Any ideas?
> > 
> > Mike
> >
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.