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

PIC18F46K80: PIN_C2, what am I missing?

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



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PIC18F46K80: PIN_C2, what am I missing?
PostPosted: Thu Sep 14, 2017 3:35 pm     Reply with quote

Edit: brain fart when typing the subject line. Fixed now.

v5.074

I know I'm missing something simple but for the life of me I just can't see it. I can't get PIN_C2 to be an output. I know that CCP2 takes priority and that timer 1's gate input may factor in too, but I can't get control over that pin no matter what I do. I've tried removing power from both CCP2 and timer 1 via their PMD (peripheral module disable) bits.

No matter what combination of values I stick in timer 1's control register, I just can't get PIN_C2 to toggle. It's an input and I can't get it to become an output.

What should I be powering off/disabling in order to take control of C2?

Code:
#include <18F46K80.h>
#device ADC=12

#FUSES NOWDT                    //No Watch Dog Timer

#use delay(clock=64000000,crystal=16000000)

#use rs232(UART1,baud=9600,errors)

#byte TXREG1=getenv("SFR:TXREG1")

void main() {
   setup_timer_1(T1_DISABLED);
   setup_ccp2(CCP_OFF);
   output_c(0x00);
   set_tris_c(0x80);
   
   while (TRUE) {
      output_high(PIN_C5);
      output_high(PIN_C4);
      output_high(PIN_C3);
      output_high(PIN_C2);
      output_high(PIN_C1);
      output_high(PIN_C0);
      delay_ms(250);
      output_low(PIN_C5);
      output_low(PIN_C4);
      output_low(PIN_C3);
      output_low(PIN_C2);
      output_low(PIN_C1);
      output_low(PIN_C0);
      delay_ms(250);
      TXREG1 = '-';
   }
}


Last edited by newguy on Thu Sep 14, 2017 3:56 pm; edited 2 times in total
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 3:38 pm     Reply with quote

Your subject is about a 18F46K22 but your include file is 18F46K80
Which are you using?
temtronic



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

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 4:07 pm     Reply with quote

Any chance it's a hardware fault?

Pin not connected, pin shorted to ground, pin shorted to VDD,pin tied to pin next to it ??


Jay
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 4:19 pm     Reply with quote

No love. Reflowed the solder on the processor and that didn't do anything.

CCS cut me a special version of pch.dll as I found a weird HIGH interrupt issue not in 5.073 but definitely in 5.074. The new dll fixed that issue but I'm wondering if it didn't introduce something else? Anyway, I sent them the test program.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 5:43 pm     Reply with quote

I tried your program just now with a DIP-40 package of the 18F46K80
on a PicDem2-Plus board and it worked. I jumpered pin C2 to pin B0
because there's an LED on that pin, and it's blinking the LED at a 2 Hz rate.
I used a Pickit3 programmer.

MPLAB vs. 8.92 reports:
Quote:
Device ID Revision = 00000002

According to pg 1 of the errata sheet, that corresponds to Silicon rev A2.
http://ww1.microchip.com/downloads/en/DeviceDoc/80000519M.pdf
The errata sheet says the current silicon rev is A6. So I have an older chip.

What silicon revision and package do you have ?
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 8:05 pm     Reply with quote

Thanks PCM. 44 pin TQFP. Not sure of the revision, will check tomorrow.

I'm wondering if my installation is corrupt? I remember several other people here have reported really weird things over the years only to have them resolved by doing a clean install. We outsource our IT to an outside company and I noticed yesterday my antivirus was reporting it was out of date, then it disappeared, then it reappeared later in the day - up to date at that. They were definitely monkeying around remotely. First thing tomorrow I'm going to try uninstalling & reinstalling. Literally at the end of my rope. A clean install can't hurt.

Come to think of it, I also hooked up a brand new ICD-U80 today. I was using my own personal ICD-U64, but I told my employer that I really needed it back home. Coworker asked me if I wanted an '80, but I told him no, a '64 would suffice. He bought the 80 anyway. It installed okay, but I did notice that CCSLoad seemed to lose USB connection with it from time to time. Coworker was away today - the 80 is now on his desk and his 64 is on mine. He bought it, he can have it. He never uses it anyway.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 9:10 pm     Reply with quote

Here is my .Hex file. You can try it.
Code:

:1000000018EF00F0EA6A050EE96EEF50D8B417EF6A
:1000100000F0140E016E006A002EFED7012EFBD7F1
:10002000BF0E006E002EFED700D0EF2EF2D71200CA
:10003000F86AD09E046AA786820EAF6E060E7D6EA9
:10004000A60EAC6E900EAB6E0F015C51800B5C6F18
:10005000000E5D6FC196C198C19A5E6B5F6BCD6AF1
:10006000AA6AF00E5017946A8B6A800E946E949A66
:100070008B8A94988B8894968B8694948B84949294
:100080008B8294908B80FA0E056E0001BBDF949AF0
:100090008B9A94988B9894968B9694948B94949234
:1000A0008B9294908B90FA0E056EACDF2D0EAD6E98
:0600B0000F01DDD7030083
:020000040030CA
:0E00000015D27E7C008991000FC00FE00F40EA
:00000001FF
;PIC18F46K80
;CRC=D58C  CREATED="14-Sep-17 16:24"
Ttelmah



Joined: 11 Mar 2010
Posts: 19557

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 1:26 am     Reply with quote

Take a different tack.

Program the pin as PWM2.
Test if you get an output.
if not, you have a hardware issue. Possibly a via under the chip that isn't connecting, or shorts somewhere it shouldn't.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 5:51 am     Reply with quote

newguy wrote:
44 pin TQFP

Carefully unsolder Pin C2 from its pad and lift it up. Do this under a
microscope. Heat the pin and use the tip of an Exacto knife to lift it off
the pad. Then use fine solderwick to clear out any solder that still
connects the pin to the pad.

Then put a scope probe lightly on the pin. My guess it that it probably
starts working.
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 7:31 am     Reply with quote

PCM: your .hex file worked. Thank you thank you thank you - that confirmed what I suspected: that my installation somehow got corrupted or was corrupted.

I uninstalled 5.074 and did a clean install. I also copied over the separate pch.dll that CCS sent me a couple of weeks ago. Recompiled & flashed the chip and I can now toggle C2 with a hex file that I created. Couldn't do that yesterday.

PCM, I know I've said this before, but not only do I owe you a beer, I think I owe you a case of beer by now.
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