Вт авг 14, 2018 11:51:27
#include <stdio.h>
#include <stdlib.h>
// PIC12F675 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
/*define clock freq*/
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000 // 4MHZ crystal
#endif
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-Up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // MCLR
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config CP = OFF // Code Protection bit (Program Memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
void mydelay_ms(unsigned int cycles) {
unsigned int i;
for (i = 1; i <= cycles; i++) {
__delay_ms(1);
}
}
void main()
{
GPIO0 = 0x00; // make all GPIO port output
TRISIO = 0x00; // TRISIO direction as output
ADCON0 = 0x00; // Internal ADC OFF
ANSEL = 0x00; // All Analog selections pins are assigned as digital I/O
CMCON = 0x07; // Shut off the Comparator
VRCON = 0x00; // Shut off the Voltage Reference
GPIO0 = 1; // Make GPIO0 port high
mydelay_ms(500);
GPIO0 = 0; // Make GPIO0 port low
mydelay_ms(130);
}
Вт авг 14, 2018 13:15:23
Вт авг 14, 2018 13:16:04
Вт авг 14, 2018 13:26:14
Вт авг 14, 2018 13:29:56
Вт авг 14, 2018 13:36:39
Вт авг 14, 2018 13:38:15
Вт авг 14, 2018 13:53:46
Вт авг 14, 2018 13:58:01
while(1)
{
GPIO0=1; // Make GPIO0 port high
__delay_ms(500);
GPIO0=0; // Make GPIO0 port low
__delay_ms(130);
}
Вт авг 14, 2018 13:59:45
mydelay_ms(130);
while(1) { }
Вт авг 14, 2018 14:01:44
Вт авг 14, 2018 14:07:29
mydelay_ms(130);
while(1) { }
Ср авг 15, 2018 11:46:19
Пт авг 17, 2018 08:18:15
Пт авг 17, 2018 12:01:00
Пт авг 17, 2018 12:49:20
Пт авг 17, 2018 13:09:31
stop:
goto stop
Пт авг 17, 2018 13:21:00
BOB51 писал(а):а как под Си...?
while(1) continue;
Пн авг 20, 2018 06:18:03
Пн авг 20, 2018 09:43:43