Main Page | File List | Globals

main.c File Reference


Detailed Description

Atmel Corporation

Originally authored by Bruce McKenny

Revision
1.5
Date
Wednesday, November 02, 2005 13:20:02 UTC

Definition in file main.c.

#include <stdio.h>
#include <inavr.h>
#include <iom64.h>
#include "icp.h"

Include dependency graph for main.c:

Go to the source code of this file.

Defines

#define CLI()   asm("CLI")
#define ENABLE_BIT_DEFINITIONS
#define LED_DEBUG_DDR   DDRC
#define LED_DEBUG_PORT   PORTC
#define SEI()   asm("SEI")
#define SLEEP()   asm("SLEEP")

Functions

void hb_init (void)
int main (void)
void pwm_init (void)
__interrupt void TIMER0_OVF (void)

Variables

unsigned char hb_count


Define Documentation

 
#define CLI  )     asm("CLI")
 

Definition at line 73 of file main.c.

#define ENABLE_BIT_DEFINITIONS
 

Definition at line 70 of file main.c.

#define LED_DEBUG_DDR   DDRC
 

Definition at line 83 of file main.c.

Referenced by main().

#define LED_DEBUG_PORT   PORTC
 

Definition at line 84 of file main.c.

Referenced by main().

 
#define SEI  )     asm("SEI")
 

Definition at line 72 of file main.c.

Referenced by main().

 
#define SLEEP  )     asm("SLEEP")
 

Definition at line 74 of file main.c.

Referenced by main().


Function Documentation

void hb_init void   ) 
 

hb_init()

Start up heartbeat timer.

It updates the duty cycle for the PWM train being Demodulated. Using the STK500's 3.6864MHz clock, and a /1024 prescale, the (8-bit) timer overflows at about 14Hz. A counter [0:4) in the ISR slows this down by 4, so the duty cycle changes apx. 3.5Hz. This isn't very precise -- it just needs to be slow enough to be visible on the LEDs.

Definition at line 129 of file main.c.

Referenced by main().

int main void   ) 
 

main()

Demonstration main program.

Definition at line 171 of file main.c.

References hb_init(), icp_init(), icp_rx(), LED_DEBUG_DDR, LED_DEBUG_PORT, pwm_init(), SEI, and SLEEP.

void pwm_init void   ) 
 

pwm_init()

Start up PWM (timer2) for demonstration purposes. It drives a non-inverted PWM train on the OC2 pin, which will be Demodulated by the ICP1 ISR (icp.c). A patch wire should be used to connect OC2 (PB7) with ICP1 (PD4).

Definition at line 151 of file main.c.

Referenced by main().

__interrupt void TIMER0_OVF void   ) 
 

Definition at line 97 of file main.c.

References hb_count.


Variable Documentation

unsigned char hb_count
 

TIMER0_OVF()

Overflow ISR for timer0. Updates the PWM duty cycle (timer2).

Definition at line 92 of file main.c.

Referenced by TIMER0_OVF().


Generated on Wed Nov 2 14:20:47 2005 for AVR135: Using Timer Capture to Measure PWM Duty Cycle by  doxygen 1.4.4