View previous topic :: View next topic |
Author |
Message |
azmi42
Joined: 06 Oct 2020 Posts: 9
|
PIC 18f46k40 |
Posted: Mon Dec 14, 2020 2:58 am |
|
|
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
|
|
Posted: Mon Dec 14, 2020 3:42 am |
|
|
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
|
|
Posted: Mon Dec 14, 2020 5:25 am |
|
|
Thank you so much, the problem is solved. _________________ software electronic development |
|
|
|