在GCC AVR里,#include <stdint.h>用来定义了数据类型。
如:
typedef signed char int8_t
typedef unsigned char uint8_t
typedef signed int int16_t
typedef unsigned uint16_t
typedef signed long int int32_t
typedef unsigned long int uint32_t
所以再用时就不用定义了,直接用就行:
程序就是使LED循环地点亮.
/*
* GccApplication9.c
*
* Created: 2014-10-3 19:31:56
* Author: Administrator
*/
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdint.h>
int main(void)
{
int8_t b=0,direction=0;
DDRA=0xFF;
while(1)
{
if(direction==0)
PORTA = 0x01<<b;
else
PORTA = 0x80 >>b;
if(++b==8)
{
b=0;
direction = !direction;
}
_delay_ms(60);
}
}
以下是仿真结果:
以下是Studio中的编译截图:
|