PDA

View Full Version : Pic12f675



Andre_Pretorius
- 5th April 2009, 19:13
Can someone please give me a indication what i am do-ing wrong i am trying to get serial coms running on a PIC12 but keeps on getting garbage the idea is to build a small data logger one input, rs232 coms and a spi ram chip



DEFINE OSC 4

DEFINE ADC_BITS 10 '10 BIT A/D CONVERSION RESULT
DEFINE ADC_CLOCK 3 'INTERNAL A/D RC CLOCK
DEFINE ADC_SAMPLEUS 50 'SET SAMPLE TIME IN MICROSECONDS
adval0 VAR WORD 'Create adval0 to store result
DATAH VAR BYTE
DATAL VAR BYTE

CMCON = 7 'TURN COMPARITORS OFF
TRISIO = %000001 'Set GSIO 0 INPUTS, others to OUTPUT
ANSEL = %00110001 'Set GSIO 0 TO ANALOG A/D IN W/Frc
ADCON0.7 = 1 'Right Justify for 10-bit

DEFINE DEBUG_REG GPIO 'Set Debug pin port
DEFINE DEBUG_BIT 2 'Set Debug pin bit
DEFINE DEBUG_BAUD 4800 'Set Debug baud rate
DEFINE DEBUG_MODE 1 'Set Debug mode: 0=true,1=inverted

DEFINE DEBUGIN_REG GPIO 'Set Debugin pin por
DEFINE DEBUGIN_BIT 1 'Set Debugin pin bit
DEFINE DEBUGIN_BAUD 4800 'Set Debugin baud rate
DEFINE DEBUGIN_MODE 1 'Set Debugin mode: 0=true,1=inverted

START:
TOGGLE GPIO.4
PAUSE 1000
DEBUG "D"

GoTo START

End

Darrel Taylor
- 6th April 2009, 00:27
This will probably help.
DEFINE OSCCAL_1K 1

But running RS232 from a 12F675's internal oscillator may not be a good idea.
Those old 4mhz internals aren't very accurate. Especially when the temperature changes.

The 12F683's have the newer precision 8Mhz internals.
Much better for serial.
<br>