|
Quote:
can't wrap my aged brain around the 'C' code examples you give
When setting up timers the only C involved is pretty much
Code:
SFR = val;
which directly translates to something like
Code:
LDI R16, val
OUT SFR, R15
so translating his C should be simple. I guess the only complication is his use of the _BV() macro and the fact he uses |= (OR with existing) and &= (AND with exitin, so when he uses code such as:
Code:
#define PORT_CT PORTB
#define DDR_CT DDRB
#define CT1A PB3 // OC1A
#define CT1B PB4 // OC1B
DDR_CT |= _BV(CT1A) | _BV(CT1B) ; /* Enable CT1 output pins */
PORT_CT &= ~(_BV(CT1A) | _BV(CT1B)); /* Set them to lo - LEDs off */
I guess the direct equivalent is:
Code:
#define PORT_CT PORTB
#define DDR_CT DDRB
#define CT1A PB3 // OC1A
#define CT1B PB4 // OC1B
#define _BV(n) (1 << n)
IN R16, DDR_CT
ORI R16, _BV(CT1A) | _BV(CT1B)
OUT DDR_CT, R16
IN R16, PORT_CT
LDI R17, _BV(CT1A) | _BV(CT1B)
COM R17
AND R16, R17
OUT PORT_CT, R16
(there may be a way to invert R17 at assemle time instead of my COM R17 but I'm afraid I don't know the Atmel assembler that well). |