AtTiny45 port PB1

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
saltuka

AtTiny45 port PB1

Post by saltuka » Sun Sep 13, 2009 8:21 pm

Hi,

I have a strage problem. I am working on a board similar to data logger but not using the HID mode. I am using open source win usb lib. Project web site is this .
http://www.harbaum.org/till/i2c_tiny_usb/index.shtml

When I connect the board to PC usb input , usb detection is OK. Device is working. When I pull down PB1 (port 6) of the Tiny45. USB comminication is broken.

PB1 port is just reading in main loop. It does not do anything else.When I make the same test with PB5 (pin1) it is OK. However I need that port as ADC so I have to use PB1 as input pin. I also use external crystal so only solution is to solve this isue.

Any idea is very appricated.

I am programming Tiny45 in High voltage programming mode fuse bits are as below.
high fuse: 01111111
low fuse: 11101000


//POWER STATE DEFINE
#define UPS_PORT PORTB
#define UPS_PIN PINB
#define UPS_DDR DDRB
#define UPS_POWER_LEVEL _BV(5)
#define UPS_POWER_STATE _BV(1)

static void keyPoll(void)
{
if (UPS_PIN & UPS_POWER_STATE)
{
//todo
}
else
{
//todo
}
}

static void timerInit(void)
{
/* select clock: 16.5M/1k -> overflow rate = 16.5M/256k = 62.94 Hz */
TCCR1 = 0x0b;

TCCR0A &= ~(0xC0);//PWM COMPARATOR OUTPUT DISABLE FOR PIN 6 (PB1)
}


int main(void) {
wdt_enable(WDTO_1S);

/* clear usb ports */
USB_CFG_IOPORT &= (uchar)~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));

/* make usb data lines outputs */
USBDDR |= ((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));

/* USB Reset by device only required on Watchdog Reset */
_delay_loop_2(40000); // 10ms

/* make usb data lines inputs */
USBDDR &= ~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));

timerInit();
usbInit();

//PCMSK &=~(UPS_POWER_STATE);
PCMSK =0x00;

ACSR &= ~(0x08); //disable analog interrupt
ACSR |= 0x80; //analog comparator disable
UPS_DDR &= ~(UPS_POWER_STATE); // port is input
/* make UPS_POWER_LEVEL outputs */
UPS_PORT &= ~(UPS_POWER_STATE); // disable pullup
GIMSK &= ~0x20; //disable pin interrupt

sei();

for(;;) { /* main event loop */
wdt_reset();
usbPoll();
keyPoll();
}

return 0;

Post Reply