SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By kaleem
hello everybody,i have written a c code function which involves watchdog timer interrupt,ADC conversion and sending the data to ouput port of controller.i am using a At tiny13 microcontroller,but firs´t i am testing on olimex board,here i am making led high each time the data is send to the output port,when i tested it out on olimex the led is blinking continuosly,i thiink the watchdog function is not working can anybody help me out.please let me know how to cross check the functionality of this code,if had checked it on avr studio simulator,simulation is fine.

heres the code

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/delay.h>
#include <avr/signal.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/iom128.h>
#define F_CPU=16;
#define TEMP=R16;
void data_send(void);
void init(void);
void delay_loop(unsigned char);
unsigned char data[3]; // data packet
unsigned char counter;
unsigned char i;
unsigned char x;
unsigned char timecount = 0;
unsigned char reset_no;
/* ADC interrupt service routine*/
{ //data[1] =ADCH; // read MSB into variable
PORTB = 0X00; // disable temp sensor
data_send(); // send packet data
ADCSRA= 0x00; // disable ADC
WDTCR= 0x0F; // WDT enable;reset mode;
MCUCR= 0x31; // enable power down sleep ;

void delay_loop(unsigned char us)

void delay_loop1(unsigned long us)

void init(void)
{DDRA= 0xFF;
ADCSRA= 0x00; // disable ADC
ACSR= 0x81; // Anlog comparator disable
//DIDR0= 0x3F; // Digital input register enable
counter=0; // initial value

void data_send(void)
{ wdt_disable();
if(data[counter/8] & (01<<(counter%8)))
{ PORTA= 0X40;
PORTA = 0X00;
else{//PORTA= 0X00;
//PORTA= 0X40;

void main(void)

asm volatile("STS reset_no,R16");
asm volatile("INC R16");
goto noteq; }
{ADCSRA= 0x00; // disable ADC
WDTCR= 0xF; // WDT enable;reset; 1.8s;
MCUCR= 0x31; // power down mode
noteq:asm volatile("CLR R16");
PORTB = 0X20; // enable temp sensor
ADMUX= 0xE6; // Vref (1.1v) , channel pB3
ADCSRA= 0xEF; // enable ADC ; start conv.
sei(); // interrupt enable
WDTCR= 0x00; // WDT enable;reset;
MCUCR= 0x21; // sleep enable ;idle mode
//while (1);

thank you
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]