Hallo,
ich habe gerade was herausgefunden. Wenn ich die Defines der IO's tausche von
Code:
#define RelaisStrobe0 PORTB = ~(~PORTB | (1<<PB0))
#define RelaisStrobe1 PORTB = (PORTB | (1<<PB0))
#define RelaisData0 PORTB = ~(~PORTB | (1<<PB1))
#define RelaisData1 PORTB = (PORTB | (1<<PB1))
#define RelaisCLK0 PORTB = ~(~PORTB | (1<<PB2))
#define RelaisCLK1 PORTB = (PORTB | (1<<PB2))
#define PowerLED1_0 PORTB = ~(~PORTB | (1<<PB3)) // rot
#define PowerLED1_1 PORTB = (PORTB | (1<<PB3))
#define PowerLED2_0 PORTB = ~(~PORTB | (1<<PB4)) // grün
#define PowerLED2_1 PORTB = (PORTB | (1<<PB4))
zu
Code:
#define RelaisStrobe0 asm volatile ("cbi 0x18, 0")
#define RelaisStrobe1 asm volatile ("sbi 0x18, 0")
#define RelaisData0 asm volatile ("cbi 0x18, 1")
#define RelaisData1 asm volatile ("sbi 0x18, 1")
#define RelaisCLK0 asm volatile ("cbi 0x18, 2")
#define RelaisCLK1 asm volatile ("sbi 0x18, 2")
#define PowerLED1_0 asm volatile ("cbi 0x18, 3") // rot
#define PowerLED1_1 asm volatile ("sbi 0x18, 3")
#define PowerLED2_0 asm volatile ("cbi 0x18, 4") // grün
#define PowerLED2_1 asm volatile ("sbi 0x18, 4")
spart mir das fast 10% Platz im AVR. Ist dies eventuell auch mit den Variablen möglich? Kann man z.B. Eine Variable in C direkt an ein Register binden und dann auch solche Optimierungen mit cbr und sbr durchführen:
Code:
U8 ShiftByte = 0;
#define RelSigLinks0 ShiftByte = ~(~ShiftByte | (1<<RelSigLinks))
#define RelSigLinks1 ShiftByte = (ShiftByte | (1<<RelSigLinks))
#define RelSigRechts0 ShiftByte = ~(~ShiftByte | (1<<RelSigRechts))
#define RelSigRechts1 ShiftByte = (ShiftByte | (1<<RelSigRechts))
#define RelPhaseLinks0 ShiftByte = ~(~ShiftByte | (1<<RelPhaseLinks))
#define RelPhaseLinks1 ShiftByte = (ShiftByte | (1<<RelPhaseLinks))
#define RelPhaseRechts0 ShiftByte = ~(~ShiftByte | (1<<RelPhaseRechts))
#define RelPhaseRechts1 ShiftByte = (ShiftByte | (1<<RelPhaseRechts))
#define RelSubLinks0 ShiftByte = ~(~ShiftByte | (1<<RelSubLinks))
#define RelSubLinks1 ShiftByte = (ShiftByte | (1<<RelSubLinks))
#define RelSubRechts0 ShiftByte = ~(~ShiftByte | (1<<RelSubRechts))
#define RelSubRechts1 ShiftByte = (ShiftByte | (1<<RelSubRechts))
#define LEDSub1_0 ShiftByte = ~(~ShiftByte | (1<<LEDSub1))
#define LEDSub1_1 ShiftByte = (ShiftByte | (1<<LEDSub1))
#define LEDSub2_0 ShiftByte = ~(~ShiftByte | (1<<LEDSub2))
#define LEDSub2_1 ShiftByte = (ShiftByte | (1<<LEDSub2))
Viele Grüße
Andreas
Lesezeichen