I spent an eternity reading PortD instead of PinD. Thank goodness for the power of web searching. Shame everyone programs in C. They are scared of the power.
NXP code
DigitalOut m1(LED1); DigitalOut m2(LED2); DigitalInOut DATA(p21); DigitalInOut CTL(p23); void set_data(unsigned char i) { DATA.write(i); m1.write(i); } void set_ctl(unsigned char i) { CTL.write(i); m2.write(i); } int main() { CTL.output(); DATA.output(); while(1) { set_data(0); set_ctl(1); wait(3); set_data(1); set_ctl(0); wait(2); } }
AVR Code
.include "m16def.inc" ; set portB to output ser r16 out ddrb, r16 clr r16 out portb, r16 ; set portD to input with pull-ups out portd, r16 out ddrd, r16 ser r16 out portd, r16 ; do the do main: in r16, pind out portb, r16 rjmp main
No comments:
Post a Comment