پاسخ : مشکل چشمک زدن LED خروجی PortC , PortD
راستش خیلی عجله دارم . یه مشکل واقعا نا خواسته بد موقع بود . ممنون میشم یه خورده زود تر .
راستش خیلی عجله دارم . یه مشکل واقعا نا خواسته بد موقع بود . ممنون میشم یه خورده زود تر .
/*
* ATmega8.c
*
* Created: 4/6/2014 9:42:15 PM
* Author: Saman.Asadi
*/
#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include </Library/iobits4ATmel_Studio.h>
#include <avr/iom8.h>
#include <util/delay.h>
#define Set_LED1 Set_D0
#define Set_LED2 Set_D1
#define Set_LED3 Set_D2
#define Set_LED4 Set_D3
#define Set_LED5 Set_D4
#define Set_LED6 Set_B6
#define Set_LED7 Set_B7
#define Set_LED8 Set_D5
#define Set_LED9 Set_D6
#define Set_LED10 Set_D7
#define Set_LED11 Set_B0
#define Set_LED12 Set_B1
#define Set_LED13 Set_B2
#define Set_LED14 Set_B3
#define Set_LED15 Set_B4
#define Set_LED16 Set_B5
#define Set_LED17 Set_C0
#define Set_LED18 Set_C1
#define Set_LED19 Set_C2
#define Set_LED20 Set_C3
#define Set_LED21 Set_C4
#define Set_LED22 Set_C5
#define max_var_PWM 99
uint8_t a = max_var_PWM,pwm[25]={0,1,3,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,99};
int main(void)
{
//Config PORTS
{
Config_ioPORTB(1,1,1,1,1,1,1,1);
Config_ioPORTC(0,0,1,1,1,1,1,1);
Config_ioPORTD(1,1,1,1,1,1,1,1);
}
//End Config ......
while(1)
{
if(a)
{
if(a == pwm[1] )Set_LED1;
if(a == pwm[2] )Set_LED2;
if(a == pwm[3] )Set_LED3;
if(a == pwm[4] )Set_LED4;
if(a == pwm[5] )Set_LED5;
if(a == pwm[6] )Set_LED6;
if(a == pwm[7] )Set_LED7;
if(a == pwm[8] )Set_LED8;
if(a == pwm[9] )Set_LED9;
if(a == pwm[10])Set_LED10;
if(a == pwm[11])Set_LED11;
if(a == pwm[12])Set_LED12;
if(a == pwm[13])Set_LED13;
if(a == pwm[14])Set_LED14;
if(a == pwm[15])Set_LED15;
if(a == pwm[16])Set_LED16;
if(a == pwm[17])Set_LED17;
if(a == pwm[18])Set_LED18;
if(a == pwm[19])Set_LED19;
if(a == pwm[20])Set_LED20;
if(a == pwm[21])Set_LED21;
if(a == pwm[22])Set_LED22;
}
if(--a == 255)
{ a = max_var_PWM;
PORTB=0;
PORTC=0;
PORTD=0;
}
_delay_us(130);
}
}
/*
* ATmega8.c
*
* Created: 4/6/2014 9:42:15 PM
* Author: Saman.Asadi
*/
#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include </Library/iobits4ATmel_Studio.h>
#include <avr/iom8.h>
#include <util/delay.h>
#define Set_LED1 Set_D0
#define Set_LED2 Set_D1
#define Set_LED3 Set_D2
#define Set_LED4 Set_D3
#define Set_LED5 Set_D4
#define Set_LED6 Set_B6
#define Set_LED7 Set_B7
#define Set_LED8 Set_D5
#define Set_LED9 Set_D6
#define Set_LED10 Set_D7
#define Set_LED11 Set_B0
#define Set_LED12 Set_B1
#define Set_LED13 Set_B2
#define Set_LED14 Set_B3
#define Set_LED15 Set_B4
#define Set_LED16 Set_B5
#define Set_LED17 Set_C0
#define Set_LED18 Set_C1
#define Set_LED19 Set_C2
#define Set_LED20 Set_C3
#define Set_LED21 Set_C4
#define Set_LED22 Set_C5
#define max_var_PWM 99
uint8_t a = max_var_PWM,pwm[25]={0,1,3,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,99};
int main(void)
{
//Config PORTS
{
Config_ioPORTB(1,1,1,1,1,1,1,1);
Config_ioPORTC(0,0,1,1,1,1,1,1);
Config_ioPORTD(1,1,1,1,1,1,1,1);
}
//End Config ......
while(1)
{
if(a)
{
if(a == pwm[1] )Set_LED1;
if(a == pwm[2] )Set_LED2;
if(a == pwm[3] )Set_LED3;
if(a == pwm[4] )Set_LED4;
if(a == pwm[5] )Set_LED5;
if(a == pwm[6] )Set_LED6;
if(a == pwm[7] )Set_LED7;
if(a == pwm[8] )Set_LED8;
if(a == pwm[9] )Set_LED9;
if(a == pwm[10])Set_LED10;
if(a == pwm[11])Set_LED11;
if(a == pwm[12])Set_LED12;
if(a == pwm[13])Set_LED13;
if(a == pwm[14])Set_LED14;
if(a == pwm[15])Set_LED15;
if(a == pwm[16])Set_LED16;
if(a == pwm[17])Set_LED17;
if(a == pwm[18])Set_LED18;
if(a == pwm[19])Set_LED19;
if(a == pwm[20])Set_LED20;
if(a == pwm[21])Set_LED21;
if(a == pwm[22])Set_LED22;
}
if(--a == 255)
{ a = max_var_PWM;
PORTB=0;
PORTC=0;
PORTD=0;
}
_delay_us(130);
}
}

دیدگاه