详细介绍:让一个灯闪耀,亮500ms后封闭500ms
流程图:
仿真图:
源代码:
//—————————————————————–
// 称号: 闪耀的LED
//—————————————————————–
// 阐明: LED按设定的时刻距离闪耀
//—————————————————————–
#include
#define LED RC5 //界说LED
//—————————————————————–
// 主程序
//—————————————————————–
void main()
{
TRISC = 0x00; //设置整个PORTC端口为输出(或设置TRISC5 = 0;)
PORTC = 0xFF; //初始时输出全1
while(1)
{
{
}
}
flowcode软件用流程图导出的源代码:
#define MX_PIC_16BIT
//Defines for microcontroller
#define P30F2011
#define MX_CLKS_PER_INST 4
#define MX_SPI1
#define MX_SPI1_PORT_B
#define MX_SPI1_SDI 5
#define MX_SPI1_SDO 4
#define MX_SPI1_SCK 6
#define MX_UART1
#define MX_UART1_PORT_B
#define MX_MI2C1
#define MX_I2C1_PORT_B
#define MX_I2C1_SDA 5
#define MX_I2C1_SCL 4
#define MX_PWM
#define MX_PWM_PORT_D
#define MX_PWM_CNT 2
#define MX_PWM_1 0
#define MX_PWM_2 7
#define P30F2011
#define MX_CLKS_PER_INST 4
#define MX_SPI1
#define MX_SPI1_PORT_B
#define MX_SPI1_SDI 5
#define MX_SPI1_SDO 4
#define MX_SPI1_SCK 6
#define MX_UART1
#define MX_UART1_PORT_B
#define MX_MI2C1
#define MX_I2C1_PORT_B
#define MX_I2C1_SDA 5
#define MX_I2C1_SCL 4
#define MX_PWM
#define MX_PWM_PORT_D
#define MX_PWM_CNT 2
#define MX_PWM_1 0
#define MX_PWM_2 7
//Functions
#define MX_Fosc 48000000
#define MX_Fosc 48000000
#define _RESERVED1(x) int temp1 = (x);
#define _RESERVED2(x) int temp2 = (x);
#define _ICD(x) _FICD(x);
#define _RESERVED2(x) int temp2 = (x);
#define _ICD(x) _FICD(x);
//Configurationdata
//Internal functions
#include “F:Program FilesMatrix MultimediaFlowcode PIC24&dsP%&&&&&% V4FCDinternals.h”
#include “F:Program FilesMatrix MultimediaFlowcode PIC24&dsP%&&&&&% V4FCDinternals.h”
//Macro function declarations
//Variable declarations
//Macro implementations
int main()
{
{
ADPCFG = 0xffff;
while (1)
{
TRISC = TRISC & 0xdfff;
if ((0<<8))
PORTC = (LATC & 0xdfff) | 0x2000;
else
PORTC = LATC & 0xdfff;
delay_ms(255);
delay_ms(245);
TRISC = TRISC & 0xdfff;
if ((1<<8))
PORTC = (LATC & 0xdfff) | 0x2000;
else
PORTC = LATC & 0xdfff;
if ((1<<8))
PORTC = (LATC & 0xdfff) | 0x2000;
else
PORTC = LATC & 0xdfff;
delay_ms(255);
delay_ms(245);
}
delay_ms(245);
}
mainendloop: goto mainendloop;
return 0;
}
return 0;
}