1

I developing RC switch for my RC glider. I have microkontroller Microchip PIC10F202 and I have problem with ON/OFF LED Lights. I want triggering input PPM signal from RC receiver, I setted GP2 as input (by T0CKI and count for every rise edge - from low to high), but LED is still ON, not reacting on input signal from RC receiver. I post my source code in C language, I can not ASM language.

// this is header file with some macros and function prototypes

#ifndef XC_HEADER_TEMPLATE_H
#define XC_HEADER_TEMPLATE_H

#include <xc.h> 

#define _XTAL_FREQ 4000000
#define KONST_ON 50
#define KONST_OFF 1000


#define STROBO_LED GP0
#define NAVI_LED GP1
#define RC_SIGNAL GP2
#define STAV_ON 1
#define STAV_OFF 0




#ifdef  __cplusplus
extern "C" {
#endif 


#ifdef  __cplusplus
}
#endif 

void setup ();
void flashing ();

#endif  

// In this function is setup for microkontroller

#include <xc.h>
#include "prototypy.h"

void setup () 
{
    OSCCAL = 0b0111111;
    //STATUS = 0b00111000;
    OPTION = 0b11100111;
    TRISGPIO = 0b0000;    

};

// This is function for LED flashing

#include <xc.h>
#include "prototypy.h"   

void flashing ()
{
    __delay_ms (KONST_OFF);    
    STROBO_LED = STAV_OFF;

    __delay_ms (KONST_ON);   
    STROBO_LED = STAV_ON;

};

// in this main function I do logical product, where I have logical state from pin GP2 and number 1

#include <xc.h>
#include "prototypy.h"


// Code protection bit
#pragma config CP = OFF
// Watchdog timer
#pragma config WDTE = OFF
// Pin function
#pragma config MCLRE = OFF



void main ()
{    
    setup ();  


    while (1)
    {      

        if (RC_SIGNAL & 1)
        {               
            flashing ();
        }     

    }       
}

Please, can me someone help and found error in my source code?

1 Answers1

0

I'am not really familar with that devive, but I guess you Pin RC_SIGNAL is not configured as an Input. Please try

TRISGPIO = 0b0100;

Mike
  • 4,041
  • 6
  • 20
  • 37