|
|
View previous topic :: View next topic |
Author |
Message |
D-Man
Joined: 06 Nov 2013 Posts: 3
|
Many Small Issues Adding Up |
Posted: Wed Nov 06, 2013 8:53 pm |
|
|
Hi,
I'm experiencing several issues that I'm starting to wonder if they are all related somehow.
I've been searching the forum and haven't found topics that have lead me down a path to solve them. Tried lots of suggestions, though.
I’m using the internal osc for the first time on a project and can’t help to think this is my issue.
Compiler 4.119
PIC16F1937 44-pin TQFP
1) Debug doesn’t work. Getting the “Could not start target: target was halted after reset Check…” Done all of the checks. It’s working any other time, just not for the debug.
2) Can’t get pin A7 (OSC1) to work as an output. I’m using pins A6 and A7 and the internal osc because I’m using just about every pin on the chip. To get around A7 not working I jumpered it to E1 and was able to continue writing code. Yes, right now E1 is electrically tied to A7. It will be challenging to cut the trace so I haven’t done it yet. Pin A6 (OSC2) is working fine as an output. A7 isn’t completely dead, as I can get a very poor square wave out of it, maybe 1vp-p and not very smooth.
3) Have to cycle the power after each time loading the program. Is this normal??? All of my previous projects I used an external osc and never had to cycle the power after each load of the program. Of course, debug worked then too.
4) #int_timer1 with a function that follows appears to make the device unresponsive. This is the strangest and the icing on the cake. I have never had a problem with interrupts, especially timers. If I comment out or remove the “#INT_TIMER1”, leaving the function, everything starts working again, except for the interrupt.
Any ideas/suggestions?
I don’t feel it’s the code, as I’m using pieces of known working code from previous projects.
I know my compiler is out of date, could this be my issue? I am able to compile without errors and what I do have written, works. Although I have noticed some strange behaviors that could be related to pins A6 & A7.
Thanks for your help in advance,
Dave |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Nov 06, 2013 8:56 pm |
|
|
Quote: |
If I comment out or remove the “#INT_TIMER1”, leaving the function, everything starts working again, except for the interrupt.
|
Hmmmmmmm.?
this forum is ABOUT CCS code
If (!code) help=0;
show the function
how you are initializing the timer and also
the code for setting up and enabling the INT handler ok??
and 4.119 may be a bit old for the PIC you want to use too |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 06, 2013 9:41 pm |
|
|
Quote: | 1) Debug doesn’t work. |
What is your debugger ? ICD2, ICD3, ICD-U64, etc. ?
Quote: | #int_timer1 with a function that follows appears to make the device unresponsive
|
Read my first reply in this thread about #int_timer1 appearing to lock up
the program:
http://www.ccsinfo.com/forum/viewtopic.php?t=51228
Quote: | Can’t get pin A7 (OSC1) to work as an output. |
Also farther down in that same link, read about pins A6 and A7 not working. |
|
|
D-Man
Joined: 06 Nov 2013 Posts: 3
|
|
Posted: Thu Nov 07, 2013 12:00 pm |
|
|
asmboy,
I hear ya. I struggled with this post, but came to the conclusion that it must be program related and not hardware related and I needed help.
PCM programmer,
I'm using the ICD-U64. Also new for me on this project is the Tag-Connect. Not sure why that would matter but thought I'd mention it.
I had found/read your post on the #int_timer1. Good point, in my haste to cut and paste, I didn't put any effort into the verifying the timing. I assumed it would be "good enough" to start and I'd get the exact timing down later. I believe T1 divide by 4 or 8 and running 8MHz INTRC_IO. At my day job right now, will check when I get home.
Also read the part about A6 & A7. Initially I didn't do anything. I let the compiler do its job. After reading the post I tried the fixed_IO, with still no luck.
A little background, I've been using CCS compilers since 2004. Always had good luck with reading posts and solving my problems on my own. Although I don't do programming at my day job any more, I still give it a try at home.
I feel skill level is probably an advanced-beginner to intermediate.
This is my first post.
It could be a few days before I can get back to this and I'll put some code up. Please stand by...
Thanks,
Dave |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Fri Nov 08, 2013 8:49 am |
|
|
The critical point was INTRC_IO.
Fixed IO only applied because the poster wanted to perform byte wide output on a port, while keeping B0/B1 as input.
Best Wishes |
|
|
D-Man
Joined: 06 Nov 2013 Posts: 3
|
Problems Solved |
Posted: Tue Nov 19, 2013 8:25 pm |
|
|
Ok, got these problems fixed.
1, 2, & 3 were fixed by removing the ECH fuse. I used the PIC Wizard thinking it would help speed up the start of my project. I also cleaned out a few other fuses that I decided weren’t needed.
Anyone have any comments on why the PIC Wizard would insert fuses that shouldn’t apply?
Here’s the original. I commented out the fuses for this post and deleted them in my program. Take note of the NOBROWNOUT fuse. Then near the bottom it sets the BORV19, I changed that too.
Code: | #include <16F1937.h>
#device ICD=TRUE
#device adc=8
#FUSES INTRC_IO //Internal Oscillator no clockout
#FUSES WDT //Watch Dog Timer
//#FUSES ECH
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES NOBROWNOUT //No brownout reset
//#FUSES IESO //Internal External Switch Over mode enabled
//#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOCLKOUT
#FUSES NOWRT //Program memory not write protected
#FUSES NOVCAP //VCAP pin disabled
//#FUSES STVREN //Stack full/underflow will cause reset
#FUSES BORV19 //Brownout reset at 1.9V
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES DEBUG //Debug mode for use with ICD
#use delay(clock=8000000,restart_wdt) |
As for my 4th problem, that was my fault. Doing some house cleaning on my code took care of the unresponsiveness. I was also inadvertently resetting the timer so it never got a chance to interrupt.
Thanks for the help. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Nov 20, 2013 1:29 am |
|
|
Key word throughout, is 'think'.
The Wizard does not 'think'.
You need to 'think'.
The Wizard will set basically all fuses, even if you are selecting others that make these 'pointless'. That doesn't actually matter at all, except in terms of wasted lines. The Wizard can setup the fuses perfectly sensibly, but _you_ need to do the thought when using it.
There are a couple of faults it perpetually has. One classic is 'setup_spi(SPI_SS_DISABLED);', where the tickbox to 'disable slave select' sets this, where the user probably actually wants to disable the SPI, not the slave select (setup_SPI(FALSE);). Generally, using the Wizard is actually likely to cost time, rather than save it, once you have any experience with the compiler at all, while for a new user, things like the above, can be very dangerous.
It is an 'accident waiting to happen', unless used with care.
Best Wishes |
|
|
|
|
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
|