Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
/********************************************** vim: set sw=8 ts=8 si :* Author: Guido Socher, Copyright: GPL * This program is to test the led connected to* PD5. * See http://linuxfocus.org/English/March2002/* for details.* Chip type : AT90S4433* Clock frequency : 4,000000 MHz*********************************************/#include "mega16.h"void delay_ms(unsigned short ms)/* delay for a minimum of <ms> *//* with a 4Mhz crystal, the resolution is 1 ms */{ unsigned short outer1, outer2; outer1 = 200; while (outer1) { outer2 = 1000; while (outer2) { while ( ms ) ms--; outer2--; } outer1--; }}int main(void){ /* enable PD5 as output */ sbi(DDRD,PD5); while (1) { /* led on, pin=0 */ cbi(PORTD,PD5); delay_ms(500); /* set output to 5V, LED off */ sbi(PORTD,PD5); delay_ms(500); }}
#ifndef __OPTIMIZE__# warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"#endif
#ifndef F_CPU/* prevent compiler error by supplying a default */#define F_CPU 16000000UL#endif
E:\root\robots\led\ledx\ledx\default/../ledx.c:34: undefined reference to `sbi'E:\root\robots\led\ledx\ledx\default/../ledx.c:37: undefined reference to `cbi'
void delay_ms(unsigned short ms)/* delay for a minimum of <ms> *//* with a 4Mhz crystal, the resolution is 1 ms */{ unsigned short outer1, outer2; outer1 = 200; while (outer1) { outer2 = 1000; while (outer2) { while ( ms ) ms--; outer2--; } outer1--; }}
it showed as warning,after adding delay.h - what should i change there ? (its in delay.h) should i delete that #warning ?
is this correct if i`m using atmega16mHz MCU ?or should i remove "UL" since my atmega does not have any letters at end of the name of it ? its simple Atmega16
what are "sbi" and "cbi" ?still have errors with them
last thing - i dont understand what for are these lines for