PDA

View Full Version : Doubt



Quicksilver
06-14-2011, 01:56 AM
Is it okay to force a pin to ground even though you define it to be a logic high and then give an if statement for forcing it to logic low?

debu
06-14-2011, 09:15 AM
Yes.

Regards,

Debu :)

Quicksilver
06-14-2011, 07:15 PM
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#include "lcd.h"
volatile uint8_t count;
volatile uint8_t j;

void main()
{
unsigned long int i;
int j,n;

unsigned long int a[5];
for(j=0;j<5;j++)
{
a[j]=0;
}
PORTD|=1;
n=0;




// Prescaler = FCPU/64
TCCR0|=(1<<CS01)|(1<<CS00);

//Enable Overflow Interrupt Enable
TIMSK|=(1<<TOIE0);

//Initialize Counter
TCNT0=0;

//Initialize our varriable
count=0;

//Enable Global Interrupts
sei();

//Initialize LCD module
InitLCD(LS_BLINK|LS_ULINE);

//Clear the screen
LCDClear();
i=0;

while(1)
{//while open
LCDWriteStringXY(0,0,"Timer");



if((PORTD&1)==1)
{


if(count!=61)
{
LCDWriteIntXY(5,0,i,4);
}

if (count==61)
{
i++;
count=0;
}
}

if((PORTD&1)==0)
{
a[n]=i;
i=0;
n++;
count=0;
}
}//while closed
}//main closed
ISR(TIMER0_OVF_vect)
{
count++;
}



This is my program. I store the value of time when PD.0 is forced to zero. But it doesnt seem to work