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

PIC 18f46k40

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



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PIC 18f46k40
PostPosted: Mon Dec 14, 2020 2:58 am     Reply with quote

Hello!

I'm using pic18f46k40 (ccs c 5.092)


I want to get output from Port A from all pins

PIN_A0, PIN_A1, PIN_A2, PIN_A3, PIN_A4, PIN_A4, PIN_A6 are working correctly and I see +5 volts at the output

but whatever i did i always see the PIN_A7 0 volts?

Code:
// code
#include <18F46K40.h>

#use delay (clock = 16000000)
 

void main () (
 
   setup_oscillator (OSC_HFINTRC_16MHZ);
   
   while (true)
   {
OUTPUT_A (0B11111111);
      DELAY_MS (100);
OUTPUT_A (0B00000000);
     DELAY_MS (100);
   }
 
}

_________________
software electronic development
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Dec 14, 2020 3:42 am     Reply with quote

Because you are not telling the compiler that you are using the internal
oscillator only. It is defaulting to setting up the clock using ECH. It only
works because it uses fail safe clock monitor, and then reaches your
instruction setting up the internal oscillator.....

Code:

// code
#include <18F46K40.h>

#use delay (INTERNAL = 16000000) //tell the compiler to use the internal
//oscillator for this

void main () {
   //This setup should not now be needed.
   setup_oscillator (OSC_HFINTRC_16MHZ);
   
   while (true)
   {
OUTPUT_A (0B11111111);
      DELAY_MS (100);
OUTPUT_A (0B00000000);
     DELAY_MS (100);
   }
}   


ECH reserves the clock input pin, so it can't be used for output...
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PostPosted: Mon Dec 14, 2020 5:25 am     Reply with quote

Thank you so much, the problem is solved.
_________________
software electronic development
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