[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] defining a different output pin

From: Blake
Subject: [avr-gcc-list] defining a different output pin
Date: Tue, 2 Dec 2003 00:21:24 -0500

Hi, I'm trying to get the sample code from the avr-libc manual to work on my board (it's a rotomotion inertial measurement board with an ATmega163 onboard, programed via a two line serial connection and a bootloader using the avr910 -dprog flag in uisp). The sample code is supposed to make an LED pulse using a PWM signal on pin D5.

My problem is that the way the board is set up pin D5 is unavailable. Pin D4 is available. Here is what the chunk of code in the sample I think I need to mess around with looks like:

#define OC1 PD5
#define DDROC DDRD
#define OCR OCR1A

#if defined(COM11)
#  define XCOM11 COM11
#elif defined(COM1A1)
#  define XCOM11 COM1A1
#  error "need either COM1A1 or COM11"

I have tried changing "#define OC1 PD5" to "#define OC1 PD4", but that doesn't seem to work. I'm guessing some of those other #defines need to be changed as well, but I really don't know how. Can anyone tell me what these lines of code are actually doing?

Here is the bit of code that initializes the I/O:

ioinit (void) /* <-- This routine gets called after a reset. */ { /* It initialized PWM and enables interrupts. */
  /* tmrl is 10-bit PWM */
  TCCR1A = _BV (PWM10) | _BV (PWM11) | _BV (XCOM11);

  /* tmrl running on full MCU clock */
  TCCR1B = _BV (CS10);

  /* set PWM value to 0 */
  OCR = 0;

  /* enable OC1 and PB2 as output */
  DDROC = _BV (OC1);

  timer_enable_int (_BV (TOIE1));

  /* enable interrupts */
  sei ();

And the final bit that actually tells the thing to output a PWM signal is simply "OCR = pwm;" where "pwm" is a volatile uint16_t that gets incremented up to 1024 and then back down to 0 every time the interrupt timer overflows.

Thanks for any help. Thinking the thing to do might just be to de-solder the board a bit so that I have access to PD5 and see if the original code works.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]