Sure,

PIC: 16F873A (brand new, tested in two units)

The pulses are counted with COUNT, the code is:

Count FREQ, 400, bPulsos

Where:

bPulsos is a byte var. The frequenci is very low, at max about 600 Hz. And "FREQ" is PORTB.0 (I´ve tried PORTC.4 and PORTC.3 also).

The basic config of the PIC is:

DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2

DEFINE LCD_DATAUS 50
DEFINE LCD_COMMANDUS 2000

DEFINE OSC 20 'MHz

DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3 ' 6uS para leitura ADC (FRC)
DEFINE ADC_SAMPLEUS 50 ' sample de 50 microsegundos

DEFINE INTHAND tmrInt
DEFINE NO_CLRWDT 1


TRISA = %11111111
TRISC = %11110111
TRISB = %00000001
ADCON1 = %10000010
OPTION_REG = %00001000
INTCON = %11000000
PIE1 = %00000010
T2CON = %01010010

I´m using Timer 2 to count time, by interruption. Also I have 3 reads of ADC (2 x LM35 and 1 potenciometer). An LCD display (16x2) is connected to PORTB.

Supply is a simple AC/DC adapter with 12.7v, regulated with a LM7805. 1000uF at in and 100nF in the out of 7805.

The pulses are generated with a function generator, very stable and calibrated with a frequencimeter. I´m using 200Hz to test the program.


This circuit must run in a car using the car battery as a power supply.

Also build a simple "low-pass" passive filter for the signal in (A 1uF and a 1,2k resistor). This cut freq about 900Hz, but not solve the problem.

All ADC readings are stable, buttons (3) sometimes don´t work.

The problem is with the count, VERY unstable.

Only for the records: The same program execute PERFECTLY in a 16F870, but 2k is very low.


If need more info, PLEASE let me know.

Thanks in advance.


Originally posted by Bruce
The more information you provide, the better your chance of someone here helping you isolate/fix the problem.

Post a few more details like;

How are you counting pulses?
Which I/O-pin are you using?
Power supply?
Config fuse settings?

Post your code - or sections of your code you're having problems with.