Recent

Author Topic: Programming help on PIC12F675  (Read 3259 times)

Teddie

  • Newbie
  • Posts: 2
Programming help on PIC12F675
« on: April 21, 2017, 11:20:06 am »
Hello,

I have a PIC12F675,and I need to program it to this:
1 OUTPUT
3 INPUTS
IF INPUT 1 and INPUT 2 receive positive impulse(at the same time),OUTPUT releases 1 positive impulse that lasts 2 seconds.
IF INPUT 1 and INPUT 3 receive positive impulse(at the same time),OUTPUT releases 2 positive impulses each lasting 1 second.

Now,I have reached the limit of my knowledge of PIC circuits.I have built PICKit 2 clone,and I have installed PICKit software and MPLAB IDE.

I have inserted the correct header,and now i need the code.

For coding,i know nothing.
So i was wondering if there are any members that can help me finish this little project of mine?

Kind regards,

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: Programming help on PIC12F675
« Reply #1 on: April 21, 2017, 11:23:50 am »
How did you embed the Free Pascal compiler in mplab? How did you configure it to generate code for the pic12 ?

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Programming help on PIC12F675
« Reply #2 on: April 21, 2017, 11:56:49 am »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Programming help on PIC12F675
« Reply #3 on: April 21, 2017, 07:27:39 pm »
You could use my new PIC compiler PicPas:

https://github.com/t-edson/PicPas

Although it has not yet support for the PIC12F675, the architecture is very similar to the 16F84.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Programming help on PIC12F675
« Reply #4 on: April 22, 2017, 12:39:08 am »
OK. Support added for the PIC12F675, in PicPas:  :D

This is the code:

Code: Pascal  [Select][+][-]
  1. {$FREQUENCY 8 MHZ }
  2. {$PROCESSOR PIC12F675}
  3. program BlinkLed;
  4. var
  5.   GPIO : BYTE absolute $05;
  6.   TRISIO : BYTE absolute $85;
  7.   //Define output
  8.   out1: boolean absolute GPIO.0;
  9.   //Define inputs
  10.   in1: boolean absolute GPIO.1;
  11.   in2: boolean absolute GPIO.2;
  12.   in3: boolean absolute GPIO.3;
  13. begin
  14.   //Set port direction
  15.   TRISIO := %00000110;
  16.   //Main loop
  17.   while true do begin
  18.     if in1 and in2 then begin
  19.        out1 := true;
  20.        delay_ms(2000);
  21.        out1 := false;
  22.        //wait until release
  23.        while in1 or in2 do begin
  24.        end;
  25.     end else if in1 and in3 then begin
  26.        out1 := true;
  27.        delay_ms(1000);
  28.        out1 := false;
  29.        delay_ms(1000);
  30.        out1 := true;
  31.        delay_ms(1000);
  32.        out1 := false;
  33.        //wait until release
  34.        while in1 or in3 do begin
  35.        end;
  36.     end else begin
  37.        out1 := false;
  38.     end;
  39.     delay_ms(100);
  40.   end;
  41. end.
« Last Edit: April 22, 2017, 12:43:44 am by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018