Что бы 8 секунд работал мотор потом 2 часа пауза потом РЕВЕРС и опять 8 секунд в работе и 2 часа пауза и так циклически...
Схему прилагаю
- Вложения
-
- реверс.png
- (26.38 КБ) 756 скачиваний
Код: Выделить всё
TRISIO= 0xFC;
while(1)
{
GPIO= 0x01;
delay_ms(8000);
GPIO= 0x00;
delay_ms(7200000);
GPIO= 0x02;
delay_ms(8000);
GPIO= 0x00;
delay_ms(7200000);
}Почему бы не показать как надо сделатьНахрена такие цены )) когда за 50р можно сделать...
Делай, братан!!!Нахрена такие цены )) когда за 50р можно сделать...
Автору:Datasheet писал(а):The ANSEL (9Fh) and CMCON (19h)
registers (9Fh) must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’. The ANSEL register is defined for
the PIC12F675.
Код: Выделить всё
#include <xc.h>
#include "pic12f675.h"
#pragma config FOSC = LP // Oscillator Selection bits (LP oscillator: Low power crystal on GP4/OSC2/CLKOUT and GP5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON // Power-Up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = ON // GP3/MCLR pin function select (GP3/MCLR pin function is MCLR)
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled)
#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)
#define _XTAL_FREQ 32768
void main(void) {
GPIO = 0x00;
CMCON = 0x07;
ANSEL = 0x00;
TRISIO = 0xFC;
while(1)
{
GPIO = 0x01;
__delay_ms(8000);
GPIO = 0x00;
__delay_ms(6000000);
__delay_ms(1200000);
GPIO = 0x02;
__delay_ms(8000);
GPIO = 0x00;
__delay_ms(6000000);
__delay_ms(1200000);
}
return;
}
Значит это полная рабочая версия прошивки ? а если всё же без кварца будет работать ? потому что время плюс-минус не очень важно ..Если до меня не выложат прошивку - приду домой скомпилю
Код: Выделить всё
#include <xc.h>
#include "pic12f675.h"
#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 = ON // Power-Up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = ON // GP3/MCLR pin function select (GP3/MCLR pin function is MCLR)
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled)
#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)
#define _XTAL_FREQ 4000000
void main(void) {
GPIO = 0x00;
CMCON = 0x07;
ANSEL = 0x00;
TRISIO = 0xFC;
unsigned char i = 0;
while(1)
{
GPIO = 0x01;
__delay_ms(8000);
GPIO = 0x00;
for ( i = 144; i > 0; i-- )
__delay_ms(50000);
GPIO = 0x02;
__delay_ms(8000);
GPIO = 0x00;
for ( i = 144; i > 0; i-- )
__delay_ms(50000);
}
return;
}
Код: Выделить всё
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))