專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開發(fā)工具、應(yīng)用測試 完善的開發(fā)代碼案例庫分享
從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!
/////////////////////////////////////////////////////////////////////////
//// UTA_1.C ////
//// This program shows how to use the pins on a PIC16F630 for ////
//// general I/O.When run, the program will run up and down the LEDs.////
//// ////
/////////////////////////////////////////////////////////////////////////
//// Copyright (C) 2006 www.czuta.com ////
//// Editor: UltraEdit-32 ////
//// Compiler: CCS PCM C Compiler, Version 3.187 ////
//// Programer:SUPERPRO 280 ////
//// Author: LiuJian(cz_utb@126.com) ////
//// Data: 2006-02-08 ////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//// Release Note ////
//// ROM used: 135 (13%) ////
//// RAM used: 2 (3%) at main() level ////
//// 3 (5%) worst case ////
/////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------//
// hardware.h
#ifndef _HARDWARE_H_
#define _HARDWARE_H_
#include <16F630.h>
/*Porta Define:
RA0: NOUSE X
RA1: NOUSE X
RA2: NOUSE X
RA3: NOUSE X
RA4: NOUSE X
RA5: NOUSE X
*/
#define TRISA_INIT 0x00
#define PORTA_INIT 0x00
/*Portc Define:
RC0: LED_1 OUT
RC1: LED_2 OUT
RC2: LED_3 OUT
RC3: LED_4 OUT
RC4: LED_5 OUT
RC5: NOUSE X
*/
#define TRISC_INIT 0x00
#define PORTC_INIT 0x00
//Out Pin Marco Define
#define SET_LED_1 PIN_C0
#define SET_LED_2 PIN_C1
#define SET_LED_3 PIN_C2
#define SET_LED_4 PIN_C3
#define SET_LED_5 PIN_C4
// UTA_1.h
#define CYCLE_DEF 250 // CYCLE=1ms*CYCLE_DEF
#endif
//---------------------------------------------------------------------//
#fuses INTRC_IO,NOWDT,NOMCLR,NOPROTECT,NOCPD,BROWNOUT,PUT
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(C)
//---------------------------------------------------------------------//
void sfrinit(void)
{
//option
disable_interrupts(GLOBAL);
set_tris_a(TRISA_INIT);
output_a(PORTA_INIT);
set_tris_c(TRISC_INIT);
output_c(PORTC_INIT);
setup_comparator(NC_NC_NC_NC);
}
//---------------------------------------------------------------------//
void userinit(void)
{
output_c(255);
delay_ms (CYCLE_DEF);
output_c(0);
delay_ms (CYCLE_DEF);
}
//---------------------------------------------------------------------//
void ledshow_forward (void)
{
output_low (SET_LED_5);
output_high (SET_LED_1);
delay_ms (CYCLE_DEF);
output_low (SET_LED_1);
output_high (SET_LED_2);
delay_ms (CYCLE_DEF);
output_low (SET_LED_2);
output_high (SET_LED_3);
delay_ms (CYCLE_DEF);
output_low (SET_LED_3);
output_high (SET_LED_4);
delay_ms (CYCLE_DEF);
output_low (SET_LED_4);
output_high (SET_LED_5);
delay_ms (CYCLE_DEF);
}
//---------------------------------------------------------------------//
void ledshow_backward (void)
{
output_low (SET_LED_1);
output_high (SET_LED_5);
delay_ms (CYCLE_DEF);
{
output_low (SET_LED_5);
output_high (SET_LED_1);
delay_ms (CYCLE_DEF);
output_low (SET_LED_1);
output_high (SET_LED_2);
delay_ms (CYCLE_DEF);
output_low (SET_LED_2);
output_high (SET_LED_3);
delay_ms (CYCLE_DEF);
output_low (SET_LED_3);
output_high (SET_LED_4);
delay_ms (CYCLE_DEF);
output_low (SET_LED_4);
output_high (SET_LED_5);
delay_ms (CYCLE_DEF);
}
//---------------------------------------------------------------------//
void ledshow_backward (void)
{
output_low (SET_LED_1);
output_high (SET_LED_5);
delay_ms (CYCLE_DEF);
userinit();
while(1)
{
ledshow_forward();
ledshow_backward();
}
}
//---------------------------------------------------------------------//