CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18LF26K22 not running

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PIC18LF26K22 not running
PostPosted: Sat Feb 17, 2018 5:59 pm     Reply with quote

Hi, I have this code:
Code:

#include <18LF26K22.h>
#fuses INTRC_IO       //Internal RC Osc, no CLKOUT                     
#fuses NOWDT, BROWNOUT, PUT, NOPBADEN, NOHFOFST                                     
#fuses MCLR                                           
#use delay(crystal=16MHz)
#use standard_io(c)

void main() {       
  set_tris_c(0x00);
   while(true){
      output_high(pin_c5);
      delay_ms(500);
       output_low(pin_c5);
      delay_ms(500);
      }
   }


I am using this PIC case
579-PIC18LF26K22IML

But I have a problem, the pic kit not found the PIC, so I used IPE of mplab... so in IPE the pic only let programming if I not select "Configuration Memory" in advance option... the software say "programming complete" but the pic no running.
If i checked option "configuration memory" the pic no let programming,
I think the hex from ccs has not the configure word or is rare...

Some help for can use this pic?
before I used this pic but wit other encapsulated and not Low voltage.. and all was ok... and the pic kit found it normal.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 7:09 pm     Reply with quote

If you want to use the internal oscillator, don't put "crystal" in the
#use delay() statement. Change it "clock" or "internal".
If you keep the INTRC_IO fuse, then you need "clock".
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 7:43 pm     Reply with quote

PCM programmer wrote:
If you want to use the internal oscillator, don't put ....


Thanks you. the code work ok, but the problem is programming the pic... Sad
I cant record the hex in this low voltage pic.

So what is the way to program that pic with the pickit?
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 8:01 pm     Reply with quote

If you're using MPLAB and a PICKit3 the following works..
From MPLAB
select Programmer->settings->power
then choose 3.5 volts

That 'should' work for you...

However what PCM P says is true, your code has the wrong xtal selection, you cannot say 'crystal' as then the PIC will expect to see a real xtal (and caps) attached to it.
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 8:12 pm     Reply with quote

temtronic wrote:
If you're using MPLAB and a PICKit3 the following works..
From MPLAB
...

Yes, Smile but still no running... I did as you said, but the mplab say "ok"
but the pic no running... If i used IPE, the only way that let programmer is not select "configuration memory" :/
With IPE I can read, erase, check ... and say "ok" to time of programmer show one error as this
http://www.microchip.com/forums/download.axd?file=0;1022635&filename=IMG-20171031-WA0017.jpg



That show mplab
Code:
Connecting to MPLAB PICkit 3...
PICkit 3 is not in programmer-to-go any more.

Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.47.12
Firmware type..............PIC18F


Device Erased...

Programming...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0xff
configuration memory
Programming/Verify complete

PICkit 3 is now in Programmer to go mode. The next time you connect to this unit, you will have the choice to take it out of Programmer to go mode.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 8:36 pm     Reply with quote

hmm..
1) IN MPLAB menu..
select project->build configuration->release
be sure 'debug' is NOT selected.

THEN compile
Then download to PIC.

2) I have NO idea how or why 'programmer to go' got selected. I've never ever used it. Perhaps someone who has will be able to help.

OK, I've re-read your post...
this..
But I have a problem, the pic kit not found the PIC..


Sounds like the PICkit 3 needs to be updated. To check ... From MPLAB
select programmer->settings->status

My PICKit3 has the following data
firmware 1.27.20
a... 1.13.03
os... 1.15.06

I just checked and under configure->select device
the PIC18LF26K22 is there.
It's actually the smaller brother to the 18F46k22 I use daily.

If you need to update,you'll need to goto the Microchip website and see how it's done. I haven't for several years but if you have a choice, select firmware 1.27.20.

BTW my version of MPLAB is 8.86.

hope this helps
Jay
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 18, 2018 6:28 am     Reply with quote

Code:

//test program
//pgm/run by PICkit3 power at 3.299 volts
#include <18F26K22.h>      //F and LF have same device header
#fuses INTRC_IO       //Internal RC Osc, no CLKOUT                     
#fuses NOWDT, BROWNOUT, PUT, NOPBADEN, NOHFOFST                                     
#fuses MCLR                                           

//#use delay(crystal=16MHz)   //does NOT work
#use delay(internal=4MHz)   //WORKS !!

//#use standard_io(c)         //not needed compiler does this
#define LED PIN_B0         //pin with LED+1K

void main() {       
//  set_tris_c(0x00);         //not needed, compiler does this
   while(true){            //flash LED at 1Hz rate
      output_high(LED);      // on 1/2 second
      delay_ms(500);      //
       output_low(LED);      // off 1/2 second
      delay_ms(500);      //
      }
   }


OK, found my 26k22 test PCB and the above code works 100%.
The PICkit3 supplies 3.299 volts and LED flashes at 1HZ rate.
Please note the comments after the clock selection.
crystal=16MHz does NOT work
internal=16MHz does work.

When you say 'crystal', the compiler assumes you have a crystal and caps attached to the clk pins but you don't, you're actual wanting to use the internal osc peripheral.

The only minor changes to your program is the #define LED PIN_B0.
Simply change PIN_B0 to PIN_C5, compile and it should work for you. By using the #DEFINE, you can save a LOT of typing and MIStyping !! If you put the LED on another pin,you only need to change the one DEFINE not a lot of other lines of code.

Also I commented out(removed) lines the compiler defaults or inserts for you.

any problems, please report back

BTW the PICkit3 automatically chose 3.299 volts not me.
Jay
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 8:58 am     Reply with quote

temtronic wrote:

...
Jay


Thanks you, but no work.
Its rare, I can read and erase the device, but the pic no let programing, on PCB I only have the PIC and one led on C5 for make the testing, I probe all router with the multimetre and all is ok.

I tried all, the pickit is updated...

Its rare because with the version 18F26K22 I have not problem, but with the low voltage version yes.
The mplab say "configure LVP pin on pickit" where I conect that pin... maybe I need that pin..?
cause show this :
Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.
Maybe the problem its connection... but all is connected... only not the pin LVP from PICkit

Reading.
Code:
Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.51.07
Firmware type..............PIC18F

Target voltage detected
Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.

Reading...

The following memory area(s) will be read:
program memory: start address = 0x0, end address = 0xffff
configuration memory
EEData memory
User Id Memory
Read complete
2018-02-19 09:54:16 -0500 - Read complete


Erasing
Code:
2018-02-19 09:56:48 -0500 - Erasing...

Erasing...
Erase successful
2018-02-19 09:56:53 -0500 - Erase device complete



When I tried programming

Code:
Connecting to MPLAB PICkit 3...

Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.51.07
Firmware type..............PIC18F

Target voltage detected
Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.
2018-02-19 10:01:42 -0500 - Loading hex file. Please wait...
Loading code from C:\Users\....test.hex...
2018-02-19 10:01:43 -0500 - Hex file loaded successfully.

2018-02-19 10:01:48 -0500 - Programming...

Device Erased...

Programming...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7f
configuration memory
program memory
Address: 0 Expected Value: 18 Received Value: 0
Failed to program device
2018-02-19 10:01:52 -0500 - Programming failed
Pass Count: 1
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 10:03 am     Reply with quote

hmm..
1st I do not use LVP, so be sure the 'fuse' is set to NOLVP in your program
also there is an option in the programmer menu to check that the fuses are controlled by the program instead of MPLAB.

2nd what version of MPLAB are you using ( I'm V8.86), as I don't get a lot of 'text' about what's happening.

3rd MY PIC to PICkit has 5 connections
Vdd, Vss,PGD,PGC and _MCLR

4th be sure to select 'power from PICkit3' option. It has more than enough power to flash the LED and that's how I tested it, powered from PICkit3.
Ttelmah



Joined: 11 Mar 2010
Posts: 19536

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 10:18 am     Reply with quote

What circuit have you got on your MCLR connection?.

What is being described is 'classic' for a board that has a too small resistor on this pin, or a capacitor connected directly to it. The programmer has to be able to pull this pin up to Vpp, reasonably quickly. Look at Figure 2-4 in the PicKit3 users guide. If you want a capacitor on the pin, it needs to be connected via a resistor not directly to the pin.
Programming is not going to work, till reading the device ID works.
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 2:08 pm     Reply with quote

The problem is communication, I don't understand what I need the pic to be read.


Ttelmah



Joined: 11 Mar 2010
Posts: 19536

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 2:38 pm     Reply with quote

The 0.1uF may well stop the programmer from working.

This is the best circuit:

[img]
http://www.microchip.com/forums/download.axd?file=0;693056&where=&f=MCLR%20Reset%20Circuit.png
[/img]

Some sites show the direct capacitor, and some programmers are powerful enough to work with this, but a lot are not, especially USB powered ones.
The 100R resistor is not necessary but increases the life of the switch.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 7:54 pm     Reply with quote

What programming program are you using? I have MPLAB 8.86 controlling a PICkit3 and do not get any of your posted messages. It appears to me you may have a 3rd party program controlling the PICkit NOT MPLAB ?
I did see a google hit about the 'stand alone PICkit3' program 'taking over' and NOT allowing MPLAB to function correctly.
Please post what your complete hardware and software consists of.

As for the _MCLR connections. On my 46K22 setup, it's just a 4k7 to Vdd, for the test 26K22, it's a 10K to VDD with a 1K in series to the MCLR pin. NO capacitor on either board.

Jay
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

PostPosted: Mon Feb 19, 2018 8:33 pm     Reply with quote

Thank you to everyone.

I get the problem... My PCB was bad, I no saw the datasheet and the QFN name pin, its diferent to SOIC.

So I soldered wire direct to PIC and the IPE mplab detect of one the PIC...
I make PCB with Proteus... and I no saw that was different.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 20, 2018 5:42 am     Reply with quote

Good news, you FOUND out why ! All my projects are done with DIP style PICs. While I can no longer read the part number on them, I can just make out the pin one 'dimple' to be sure it's inserted into the socket properly.
Bad news, you've found another reason why Proteus cannot be trusted. It SHOULD have known about the different pinouts between PIC packages!

Hopefully you can get the PIC to flash the LED and continue soon !

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group