Author Topic: K150 PIC programmer - simulation works but reality doesn't  (Read 1478 times)

0 Members and 1 Guest are viewing this topic.

Offline angelothewolfTopic starter

  • Contributor
  • Posts: 43
K150 PIC programmer - simulation works but reality doesn't
« on: December 12, 2017, 07:20:25 pm »
Hello there,

I'm a beginner in PIC programming and I'm trying to run a simple Blinking Led program. I'm using MikroC Pro, Proteus 8 Professional and a K150 PIC programmer. I have a PIC 16F818.

The code is:

#pragma config OSC = INTIO1
#pragma config WDT = OFF
void main()
{
     OSCCON = 0x70;
     TRISA = 0x00;
     PORTA = 0x00;

     while(1)
     {
      PORTA = 0x01;
      delay_ms(500);
      PORTA = 0x00;
      delay_ms(500);
     }
}

The simulation in Proteus is working fine (although it takes 2 seconds for the led to blink). The K150 programmer seems to be working as well (it doesn't report any warnings). But when I set the circuit on the protoboard, the led lights up but never turns off. I've tried some variations of this code, using other ports, different delay times, but the same problem occurs. I don't think it is necessary to configure the internal oscillator or disable the watchdog timer, but I've tried it anyway. I've attached an image of the circuit simulation. The connections on the protoboard seems to be correct, with 5V on VDD (Pin 14) and GND on VSS (Pin 4).

Does anyone have any suggestions?
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: K150 PIC programmer - simulation works but reality doesn't
« Reply #1 on: December 12, 2017, 08:36:06 pm »
Hi,

PortA is by default set to Analogue Input, so you need to use ADCON1 to set it to Digital, followed by TRISA to Outputs.

Or just use PortB instead, which is Digital by default.

As for your simulation running slow, have you changed its default clock speed, often 1Mhz; the Sim usually ignores OSCON in your code.
« Last Edit: December 12, 2017, 08:41:59 pm by picandmix »
 

Offline angelothewolfTopic starter

  • Contributor
  • Posts: 43
Re: K150 PIC programmer - simulation works but reality doesn't
« Reply #2 on: January 15, 2018, 07:32:26 pm »
Thanks for the reply. You are right, but the problem was that I've accidentally burned the chip. I've used PortB in a new chip and it worked.
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: K150 PIC programmer - simulation works but reality doesn't
« Reply #3 on: January 15, 2018, 08:41:11 pm »
Glad you have got it working, though you do not need to use a new chip each time your reprogram.

Modern Pic chips flash program memory can be rewritten many thousands of times, the programmer takes care of all that for you.

In your other thread, as said, unless your voltage is very steady and all connections very firm,  the Least Significant one or two Bits may well flash on/off or dim.   Placing 100nf and say 10uf capacitors close to and across the vdd and vss pins of the pic will help reduce that effect

As you turn your pot, you may also get uneven led values as it could be moving/changing resistance as it takes the ADC reading from it. though it should stabalize once you stop turning.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf