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

24FV16KA301 cannot blink
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

24FV16KA301 cannot blink
PostPosted: Thu Apr 23, 2015 10:37 am     Reply with quote

Hi

I have programmed several 16 bit microchips with CCS before, but I cannot get anything out of this 24FV16KA301. I made some example code in the CCS C Compiler (below) and am using it in MPLAB IDE v8.92, with a pickit3 for programming. I checked all the connections; the microcontroller is getting 5V and ground, MCLR, PGD, and PGC are connected to the ISCP 1 pins correctly. I have the correct device selected in MPLAB. And I have CCS C Compiler selected under Select Language Toolsuite. I also have the 24bit version of CCS and can see the header file located in the PICC\Devices directory. I have tried blinking on many different pins on banks A and B, but still the oscilloscope shows nothing on the pins. The program compiles and programming is verified.

Any suggestions are very much appreciated!
Code:

#include <24FV16KA301.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT               //No brownout reset

#device ICSP=1
#use delay(internal=8MHz)

#use FIXED_IO( A_outputs=PIN_A4 )

#define LED PIN_A4
#define DELAY 1000

void main()
{
   //Example blinking LED program
   while(true)
   {
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
   }
}
jeremiah



Joined: 20 Jul 2010
Posts: 1344

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 1:36 pm     Reply with quote

Either try a different pin, or you need to go back and add more FUSES to your program. A4 is on a special pin that doesn't default to digital like most of the pins do. There is a FUSES configuration that sets it to digital.

Additionally, you really need to go back through and add more FUSES anyways. Unrelated to your current problem probably, but there are two oscillator fuses that should be specified or you can risk the defaults not running your clock at the correct speed.

If you were using the CCS IDE, I would suggest using the Valid Fuses (v4 compiler) or Configuration Bits (v5) button to see all the options and go from there comparing them to the data sheet. Since you are using MPLAB, I don't know the normal way of getting that outside just looking at the fuses.txt file in the install directory and comparing to the data sheet, but that is a lot more work.

EDIT: Also, no need for fixed_io. The compiler will set the TRIS for you when you call output_low/output_high/output_toggle/etc.
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 2:05 pm     Reply with quote

Thank you for the reply! I will use CCS C Compiler to find fuses and add them to my code. However, I did try using a bunch of different pins, from banks A and B.

The only reason I use MPLAB is because I could not get the pickit3 to connect to the C Compiler. So I just copy the code over to MPLAB after using the CCS project wizard.
temtronic



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

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 2:21 pm     Reply with quote

hmmm.. have you set mplab 'build configuration' to 'release' instead of the default of 'debug'?

That one will nail you !!!

Jay
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 2:26 pm     Reply with quote

Hi Jay

No. When I go to Project>>Build Configurations it says "(No Build Configurations)" and it is grayed out.

And just looking at another project where I use a PIC16F1827 the Build Configuration is the same way. Also, I didn't have to add any fuses either. Hmmm, I guess that was just a much simpler microcontroller.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 23, 2015 2:51 pm     Reply with quote

Quote:
When I go to Project>>Build Configurations it says "(No Build Configurations)" and it is grayed out.

See this post. It tells how to fix it, if Build Configuration (Release / Debug)
is grayed out in MPLAB vs. 8.92:
http://www.ccsinfo.com/forum/viewtopic.php?t=46950&start=7
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 8:52 am     Reply with quote

Thank you for the suggestions!

I tried adding #fuses SOSC_DIGITAL and tried using other pins on bank B. But still no output. I also tried setting the Build Configuration to Release (after installing the plug-in it was no longer grayed out), and still nothing.

I tried the same code with a 16F1827 (just switched the #include and Select Device in MPLAB) and it works.

Code:
#include <24FV16KA301.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT               //No brownout reset
#fuses SOSC_DIGITAL     //SOSC pins set for Digital mode for use with external clock or Digital I/O

#device ICSP=1
#use delay(internal=8MHz)

#use FIXED_IO( B_outputs=PIN_B4 )

#define LED PIN_B4
#define DELAY 1000

void main()
{
   //Example blinking LED program
   while(true)
   {
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
   }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19494

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 10:37 am     Reply with quote

1) What compiler version?.
2) Get rid of the fixed IO. It's a complexity that is not wanted at this point.
3) The instinct is that the chip may not be running at all. That it behaves the same on other pins suggests this.
Try explicitly selecting FRC, NOWDT, NOMCLR.
This may be one of the chips where the watchdog is enabled by default. As such it might be starting, setting the line low, and then restarting. It'd then not seem to be running. There are a number of newer chips where this is the case, hence it is always worth trying disabling it.
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 10:59 am     Reply with quote

Compiler version 5.026

No change after removing the fixed IO.

I have these fuses:
#FUSES NOWDT
#fuses FRC
#fuses NOMCLR

And still nothing
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 11:09 am     Reply with quote

Actually #fuses NOMCLR gives the following error:

The following memory regions failed to program correctly:
Configuration Memory
Address: 00f8000c Expected Value: 0000007c Received Value: 000000fc
Programming failed
fftftw



Joined: 23 Apr 2015
Posts: 8

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 11:53 am     Reply with quote

Well this is embarrassing. I just changed the chip and it fixed it. Its odd because changing the chip was one of the first things I tried, but I must have broken 2 of them. I wish the programmer would throw some kind of error if the chip is burned out.

Thanks everyone for your help!
Ttelmah



Joined: 11 Mar 2010
Posts: 19494

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 2:08 pm     Reply with quote

Or, there is a batch problem.....

I've had large groups of faulty chips (had to return over 10000 at one point...). It'd be worth reading the chip ID number on the working one and the faulty ones and see if there is a difference. Other possibility is that something is not erasing properly (one poster here had a problem that if he selected a particular clock setting, a chip became 'unrecoverable', and had to be replaced by Microchip).
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 2:10 pm     Reply with quote

Just to add...

#use delay(internal=8MHz)

don't rely on the internal word for delays that automatically activate the internal oscillator... had this kind of problem in the past with CCS v4

Just use FRC fuses it's safer...
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
jeremiah



Joined: 20 Jul 2010
Posts: 1344

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 2:20 pm     Reply with quote

You also want to specify the clock circuit fuse (HS,XT,EC,NOPR) as NOPR. Almost all PIC24s have two oscillator fuses:

HS,XT,EC,NOPR - specifies the circuit to use
PR,FRC,LPRC,PR_PLL, etc. - controls the clock mux
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Fri Apr 24, 2015 2:46 pm     Reply with quote

jeremiah wrote:
You also want to specify the clock circuit fuse (HS,XT,EC,NOPR) as NOPR. Almost all PIC24s have two oscillator fuses:

HS,XT,EC,NOPR - specifies the circuit to use
PR,FRC,LPRC,PR_PLL, etc. - controls the clock mux


He's right! Smile

Got bite by that the first time I've tried PIC24 platform...

Datasheet is your friend too ..specially when exploring new stuff ;)
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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