Lazarus

Programming => General => Topic started by: Teddie on April 21, 2017, 11:20:06 am

Title: Programming help on PIC12F675
Post by: Teddie on April 21, 2017, 11:20:06 am
Hello,

I have a PIC12F675 (http://www.kynix.com/uploadfiles/pdf8798/PIC12F675-E2fMD.pdf),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,
Title: Re: Programming help on PIC12F675
Post by: marcov 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 ?
Title: Re: Programming help on PIC12F675
Post by: eny on April 21, 2017, 11:56:49 am
http://www.pmpcomp.fr/
Title: Re: Programming help on PIC12F675
Post by: Edson 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.
Title: Re: Programming help on PIC12F675
Post by: Edson 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.
TinyPortal © 2005-2018