PDA

View Full Version : Problems with PIC12CE674



Lionheart
- 3rd December 2008, 10:28
I have only connected de main supply at the the PIC12CE674, because in the configuration word you can chooce to turn on the 4MHz clock inside and the reset internally connected to VDD.

So i think there is nothing wrong with the hardware.

For the program:
'Register Initializations'
TRISIO.0 = 1
TRISIO.1 = 0
TRISIO.2 = 0
TRISIO.3 = 1
TRISIO.4 = 1
TRISIO.5 = 1


'Variabelen
Input_1 VAR GPIO.4
Input_2 VAR GPIO.5
Output_1 VAR GPIO.1
Output_2 VAR GPIO.2
Memory_1 var bit
Memory_2 VAR bit
Max_Pulsen VAR WORD
Pulsen_1 VAR WORD
Pulsen_2 VAR WORD



Max_Pulsen = 100

Main: if (Input_1=1 & Memory_1=0) then
Pulsen_1 = Max_pulsen
Memory_1 = 1
ENDif

if (Input_2=1 & Memory_2=0) then
Pulsen_2 = Max_pulsen
Memory_2 = 1
ENDif

if (Pulsen_1 > 0) then
Toggle Output_1
else
Memory_1 = 0
output_1 = 0
endif

if (Pulsen_2 > 0) then
Toggle Output_2
else
Memory_2 = 0
output_2 = 0
endif

pause 1000 'pause van 1sec
goto main
end

The thing i i'm not sure about are the ID locations. I left them at FFFF

Thanxs at advance

Lionheart
- 3rd December 2008, 10:31
Sorry forgot to mention the problem :p.

The PIC12CE674 doesn't do anything.

Darrel Taylor
- 3rd December 2008, 12:55
First off, I can't believe you're using a 12CE674 :eek:
Well, if you must ...
Here's a few pointers.

1: ID locations don't matter. They don't have an effect on the processors functions.

2: Turn off the Analog pin functions.
    ADCON1 = 7

3: Move factory calibration to OSCCAL
    DEFINE OSCCAL_2K 1

4: For ease of use, put the Configs in your program.

@ device INTRC_OSC ; Internal Oscillator
@ device MCLR_OFF ; Turn OFF Master Clear Reset
@ device WDT_OFF ; Turn OFF WatchDog Timer

5: Initialize variables at the beginning of the program.
    Reasoning: When the program gets to Main:, the state of Memory_1 is not known.

Main: if (Input_1=1 & Memory_1=0) then


You can either set each variable to a specific value, or just put a CLEAR statement at the top of the program, and everything will start off at 0.

6: Initialize your output states before setting TRISIO.
    CLEAR does not initialize the PIN states. So you have to do those manually.

GPIO = 0
TRISIO = %111001


HTH,

Lionheart
- 4th December 2008, 18:49
The PIC12CE674 has the right amount of pins that's why i choose this one.

I will try your advice now.

Thanxs alot.

Lionheart
- 4th December 2008, 21:00
It's working thanxs for your help Darrel.