Disha Karnataki
Full Member level 5
- Joined
- Jul 20, 2013
- Messages
- 249
- Helped
- 9
- Reputation
- 18
- Reaction score
- 8
- Trophy points
- 18
- Location
- india
- Activity points
- 2,231
this is my code :
what is mistake in this code as only 0X0A value is shown on PORTB.
Code:
#include <avr/io.h>
void tim0(unsigned int);
int main(void)
{
DDRB=0X0F; //making lower nibble o/p port
PORTB=0X00;
TCCR0=0X01; //timer with no prescaler
TCNT0=0X00; //initial count value=0x00
while(1)
{
PORTB=0X0A; //portb has 0x0a value
tim0(90); //set some delay
PORTB=0X00; //portb value =0x00
tim0(90); //set some delat
}
}
void tim0(unsigned int x) //sub routine for delay
{
unsigned int i;
for(i=x;i>0;i--)
{
if(TCNT0!=190); //loop till tcnt value becomes 190
TCNT0=0; //reset the tcnt value back to zero
} //continue this loop till i=0
}