problem with a program that uses the watchdog

Status
Not open for further replies.

mostafa272

Junior Member level 3
Joined
Dec 16, 2010
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,493
Hi

this is a program that uses the watchdog timer to show "HELP" message on 7-segment.I don't know what are sram array and location=0x60 in this program,and what are their roles?why point is counted to 8?please explain it!

thanks

Code:
/****************************************
* MDA-MULTI MICOM AVR
* MCU : AVR
* COMPILER : IAR
* FILE NAME : WATCH.C
****************************************/

/*****************************************
        < Jumpering >
PA0 ~ PA7 ==> [7-SEGMENT] A ~ P
PB4 ~ PB7 ==> [7-SEGMENT] Q0 ~ Q3
******************************************/
/* This header file declares the internal
   register addresses for Atmega 8535 */
#include "io8535.h"
                              // P        L         E         H
__flash unsigned char SEG[8] = {0x8c,0xef,0xc7,0xdf,0x86,0xbf,0x89,0x7f};

#pragma location=0x60
__no_init char SRAM[2];
// Main
void main(void)
{
    unsigned char point;
    // Definde directions for port pins
    DDRB = 0xff;
    DDRA = 0xff;
    PORTA = 0xff;
    PORTB = 0xff;
    asm ("WDR");   // Reset watchdog
    WDTCR = 0x18;
    point = SRAM[0];
    if (point != 1){
        SRAM[0] = 1;
        SRAM[1] = 0;
    }
    point = SRAM[1];
    if (point == 8) SRAM[1] = 0;
    point = SRAM[1];
    PORTA = SEG[point];
    point++;
    PORTB = SEG[point];
    point++;
    if (point == 8) point=0;
    SRAM[1] = point;
    while(1);
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…