AVR Studio won't connect to LV-168 anymore?

Hey there,

I’ve been programming the ATmega168 on the Orangutan LV-168 in assembly with the USB Programmer that it came with. Problem is, just recently I have been unable to connect to the connect to the target device. In the “Select AVR Programmer” Prompt, I select AVRISP and Auto (or COM3 in my case) and the window returns with “Connect Failed” at the top. What gives? I did a fresh install of Windows 7 Professional x86 and I installed all of the Windows Vista drivers from this site’s page for the USB Programmer that I have (it’s the one without the SLO function, older one). I set the port settings to 115200-8-N-1 and I can verify that the latest program I flashed on the ATmega168 is working correctly because I can communicate with it via PuTTY with the USB Programmers’ Serial Communications mode. (The program receives characters via USART0 and commands a tank with two DC motors using the motor controllers connected to PORTD and PORTB). I also noticed that the red LED on the LV-168 located by the reset button is now red, but I think that’s because I have PD1(USART0 Tx) connected to Rx on the USB Programmer.The following is my code for the program that should be on there now:

.INCLUDE "m168def.inc"

.DEF tmp = R16
.DEF counter = R17
.DEF tosetstack = R18
.DEF char = R19

.EQU M1A = PD5
.EQU M2A = PD3
.EQU M1B = PD6
.EQU M2B = PB3

.ORG 0x00
	RJMP 	reset

.ORG URXCaddr			;This defines what to do if USART0 Rx interrupt is triggered
	RJMP	rx_char		;So jump to our interrupt subroutine below

.ORG INT_VECTORS_SIZE	;This starts the main instructions outside of the vector addresses
    LDI 	tosetstack, HIGH(RAMEND);Upper byte of ramend
    OUT 	SPH,tosetstack			;to stack pointer high
    LDI 	tosetstack, LOW(RAMEND) ;Lower byte of ramend
    OUT 	SPL,tosetstack 			;to stack pointer low

	SEI					;Enable Interrupts

	SBI		DDRB, M2B	;Set Motor 2 B to output
	LDI		tmp, 0x68
	OUT		DDRD, tmp	;Set Motor 1 A & B, and Motor 2 A to output

	LDI		tmp, 129	;We want baud 9600
	STS		UBRR0L, tmp	;Set low byte for baud to 0x81=129 (depends on cpu clock)
	LDI		tmp, (1<<RXCIE0)|(1<<RXEN0)|(1<<TXEN0)
	STS		UCSR0B, tmp	;This sets receive enable, and receive interrupt enable
	LDI		tmp, (3<<UCSZ00)	
	STS		UCSR0C, tmp	;Set character size to 8bit, default stop =1, didn't set any parity

	LDI		tmp, (1<<SE)
	OUT		SMCR, tmp	;Enable SLEEP commands. Because pins 1-3 are 0-0-0, IDLE sleep is active

	LDI		tmp, 0x79	;This selects all pins in PRR except USART0 and SPI
	STS		PRR, tmp	;Power Reduction Register set
	SLEEP				;The processor goes idle while it waits for an interrupt by USART0 Rx Complete
	RJMP	main	

	LDS		char, UDR0	;Read the character from the buffer into "char" = R19
	STS		UDR0, char	;Echo the character back to the controlling terminal
	CPI 	char, 'w'	;Compare character with 'w'
	BREQ	forward		;If equal, jump to forward
	CPI		char, 's'
	BREQ	reverse
	CPI		char, 'a'
	BREQ	left
	CPI		char, 'd'
	BREQ	right
	RJMP	brake		;Any other character received, brake				

	SBI		PORTB, M2B	;Drive Motor 2 B high
	SBI		PORTD, M1B	;Drive Motor 1 B high
	CBI		PORTD, M2A	;Drive Motor 2 A low
	CBI		PORTD, M1A	;Drive Motor 1 A low
	RETI				;Return from interrupt

	SBI		PORTD, M2A	;Drive Motor 2 A high
	SBI		PORTD, M1A	;Drive Motor 1 A high
	CBI		PORTB, M2B	;Drive Motor 2 B low
	CBI		PORTD, M1B	;Drive Motor 1 B low
	RETI				;Return from interrupt

	SBI		PORTB, M2B	;Drive Motor 2 B high
	SBI		PORTD, M1A	;Drive Motor 1 A high
	CBI		PORTD, M1B	;Drive Motor 1 B low
	CBI		PORTD, M2A	;Drive Motor 2 A low
	RETI				;Return from interrupt

	SBI		PORTD, M1B	;Drive Motor 1 B high
	SBI		PORTD, M2A	;Drive Motor 2 A high
	CBI		PORTB, M2B	;Drive Motor 2 B low
	CBI		PORTD, M1A	;Drive Motor 1 A low
	RETI				;Return from interrupt

	SBI		PORTB, M2B	;Drive Motor 2 B high
	SBI		PORTD, M1B	;Drive Motor 1 B high
	SBI		PORTD, M2A	;Drive Motor 2 A high
	SBI		PORTD, M1A	;Drive Motor 1 A high
	RETI				;Return from interrupt

Can someone please help me figure out why I can’t connect to the ATmega168 to program it anymore?

EDIT: I also tried updating the firmware to version 1.4 (I have the PGM02B programmer) and changing the software version to say 2.07 (it was 2.0a before). No luck - I keep getting told by AVR Studio that the connect failed.

EDIT: So avrdude works, but AVR Studio doesn’t want to connect. This means that the drivers for the USB Programmer are fine. Does AVR Studio use avrdude? I’d like to be able to program from the GUI without having to open a command prompt and running the command there. Maybe AVR Studio just doesn’t work correctly in Windows 7 (even 32-bit); I installed it and WinAVR both as an administrator.

Okay, I think I got AVR Studio to connect to the LV-168 for good now through the Pololu USB Programmer. All I know is that I ran the installer in Compatibility mode for “Windows XP Service Pack 2” and I left the “Jungo” driver checkbox ticked. I opted to not install the Jungo driver last time because I thought the programmer was emulating AVRISP (the original) and because I was not using an AVRISP mkII or STK600 or AVR Dragon to program the ATmega168. Why was I under the impression that it was AVRISP and not AVRISP mkII? Because when I had AVR Studio installed before I could only connect to the LV-168 by selecting “AVRISP” or “STK500” in the Connect dialog.

So can someone from Pololu please clarify if I need to install the “Jungo” drivers that are checked by default in the AVR Studio install in order for the programmer to work? Or maybe explain what the programmer is seen as by the PC?

From my understanding the programmer has a USB-to-UART bridge which creates a virtual serial port(we need drivers on the Windows machine to recognize this bridge and set up the COM port). The jumper on the programmer seems to just pass the UART output of this bridge to either some other UART input (like the pins on the ATmega168) or to another processor on the programmer that runs software which emulates the AVRISP. Is this right? If so then I don’t understand the need to install Jungo drivers for USB communication.

Thanks =D


Your understanding of the programmer sounds correct; I do not know why the installation with the Jungo drivers made a difference. We generally haven’t worked with Windows 7 much yet. Was the programmer working fine for you in Windows 7 for a while, or did it quit working when you moved to Windows 7?

- Jan

Hey Jan,

Well, AVR Studio couldn’t connect from the start without Jungo drivers in Windows 7, but avrdude from WinAVR worked fine so I knew the problem should have been AVR Studio specific. To be honest, I can’t remember if I had them installed on XP before I made the transition. But all seems to be fine now with Jungo drivers installed in addition to the USB Programmer drivers provided here