Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
#define sbi(a, b) (a |= (1 << b))#define cbi(a, b) (a &= ~(1 << b))
PORTD = 0xF0 //7-4 on, 3-0 off
uint8_t gigi; //our shadow buffer is named gigigigi = PORTD;gigi = PORTD | 0x80; (binary: 10000000)PORTD = gigi; //bit 7 is now set//waitgigi = PORTD;gigi = PORTD & 0x7F; (binary: 01111111)PORTD = gigi //bit 7 is now clear
PORTD |= (1 << 7)
PORTD.3=1 // on PORTD.3=0 // off
PORTD |= (1 << 6)
Thanks iuza it helped a litle,but i still dont know what i should change in code to open other ports since there are no nummbers >.<are there any libary who i could inclide, and c will know what port i`m gona use ? like just writingCode: [Select]PORTD.3=1 // on PORTD.3=0 // off or similar ?? atleast on previus test codes i have seen that, but they didnt work
[code]not in avr, ffs. you should have mentioned that. do instead of[code]#define sbi(a, b) (a |= (1 << b))#define cbi(a, b) (a &= ~(1 << b))
#define set_bits(a, b) (a |= (1 << b))#define clear_bits(a, b) (a &= ~(1 << b))
i did and AVR Studio sayd something about sbi/cbi allredy defined ...
/********************************************** Author: Karlis* This program is to test the led connected to* PD4. * Chip type : ATmega16* Clock frequency : 16,000000 MHz*********************************************/#include <avr/io.h>#include <mega16.h>#include <util/delay.h>#define sbi(a, b) (a |= (1<< b))#define cbi(a, b) (a &= ~(1 << b))#define set_bits(a, b) (a |= (1 << b))#define clear_bits(a, b) (a &= ~(1 << b))void delay_ms(unsigned int time_ms){ while (time_ms--) _delay_ms(1);}int main(void){ /* enable PD4 as output */ sbi(DDRD,PD4); while (1) { /* led on, pin=0 */ cbi(PORTD,PD4); delay_ms(50); /* set output to 5V, LED off */ sbi(PORTD,PD4); delay_ms(50);} //test flash 2 led on port D5 sbi(PORTD,PD5); while (1) { delay_ms(100); cbi(PORTD,PD5); delay_ms(100); sbi(PORTD,PD5); delay_ms(100);}}