Cannot make 16F88 work

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
komichal
Posts: 4
Joined: 13 Jun 2018 20:41

Cannot make 16F88 work

#1 Post by komichal » 13 Jun 2018 20:49

Hello everybody,
so far I have been messing around with only 16F84 but now I need to switch to 16F88 because of more memory.

My problem is that I cannot make my code work. I believe I am doing some trivial mistake with datasheet readings. Can anyone please help? I have disabled analog inputs, comparators and interrupts - but there must be something more?

Even this easy "hello world" code that should blink the LED does not work:

Code: Select all

program MyProject;

begin
  TRISA := %00000;                  
  ANSEL := 0;                       
  CMCON := 0;                       
  INTCON := 0;
  PORTA := %00000;                   

  while true do
        Begin
             PORTA.0 := 1;
             Delay_ms (1000);
             PORTA.0 := 0;
             Delay_ms (1000);
        End;

end.
The LED just goes ON and never powers off.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Cannot make 16F88 work

#2 Post by janni » 14 Jun 2018 11:50

Try

Code: Select all

CMCON := 0x07;
to disconnect comparator inputs.

komichal
Posts: 4
Joined: 13 Jun 2018 20:41

Re: Cannot make 16F88 work

#3 Post by komichal » 15 Jun 2018 20:45

Yeah I tried that (actually you are right - this is the correct way according to the datasheet) but no change in behavior.

My schematics (I replaced the LED with a transistor and a relay):
https://screenshot.net/wmk0qu5

I suppose there is no need to wire in a resistor to MCLR as it is defined as IO with config bits, correct?
Whole circuit is currently powered by 3 fresh AA baterries (voltmeter says 4.8V even with the relay engaged)

My config bits look also OK:
https://screenshot.net/w5897i8

I am running out of ideas... I have bought another 16F88 and it behaves the same. I tried every single IO from the circuit and they are all behaving the same. Anything else worth checking please?

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Cannot make 16F88 work

#4 Post by filip.grujcic » 18 Jun 2018 13:58

Hello,

Could you please try to load the configuration scheme I attached and see if it will work after you've done that?

Project --> Edit Project --> Load Scheme...

Kind regards,
Attachments
P16F88.zip
(621 Bytes) Downloaded 113 times
Filip Grujcic

komichal
Posts: 4
Joined: 13 Jun 2018 20:41

Re: Cannot make 16F88 work

#5 Post by komichal » 18 Jun 2018 20:47

Hello there,
with this config scheme the relay wildly and irregularly oscillates (oscillation period varies between some 100ms and 5s).

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Cannot make 16F88 work

#6 Post by filip.grujcic » 19 Jun 2018 14:41

Hello,

Try adding the line OSCCON := %01110100; at the beginning of main, using your config scheme and set the frequency to 8 MHz in the Project Settings window.

Kind regards,
Filip Grujcic

komichal
Posts: 4
Joined: 13 Jun 2018 20:41

Re: Cannot make 16F88 work

#7 Post by komichal » 19 Jun 2018 20:22

Hi Filip,
thank you very much, that OSCCON did the trick! I have to check the datasheet what exactly is affected by this and why it started to work. :)
Thank you and cheers!
Michal

Code: Select all

ANSEL := 0;                       
CMCON := 0x07;                       
INTCON := 0;
OSCCON := %01110100;

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Cannot make 16F88 work

#8 Post by filip.grujcic » 20 Jun 2018 08:26

Hi,

It's the oscillator settings register.

You're welcome, glad I could help.

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroPascal PRO for PIC General”