|
|
View previous topic :: View next topic |
Author |
Message |
tysie
Joined: 14 Nov 2017 Posts: 7
|
using C1 on 18F45k22 |
Posted: Thu Dec 21, 2017 4:16 am |
|
|
Hi,
I want to use C1 as a normal output at the 18F45K22.
I cannot use it because by default it is used for SOSCI.
How can I disable SOSCI and use the pin as an output in ccs? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Dec 21, 2017 4:51 am |
|
|
By default it will be available to you. Depends on how you have the timers and clock setup. On some chips there is a fuse that has to be set, but not on this one.
It is not used as SOSC 'by default'. Only if the secondary oscillator is enabled for something.
If it is not working for you post a small program (clock, timer settings etc., only), that will compile and show the problem. |
|
|
tysie
Joined: 14 Nov 2017 Posts: 7
|
|
Posted: Thu Dec 21, 2017 4:53 am |
|
|
part of the main:
Code: | setup_adc_ports(sAN11);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_2); //32,7 ms overflow
setup_timer_2(T2_DIV_BY_16,190,1);
setup_ccp4(CCP_PWM);
//set_pwm4_duty((int16)300);
set_pwm4_duty((int16)0);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL); |
header:
Code: | #include <18F45K22.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(internal=16MHz)
#use FIXED_IO( A_outputs=PIN_A7,PIN_A6,PIN_A5,PIN_A4,PIN_A1,PIN_A0 )
#use FIXED_IO( B_outputs=PIN_B3,PIN_B2,PIN_B1,PIN_B0 )
#use FIXED_IO( C_outputs=PIN_C7,PIN_C6,PIN_C5,PIN_C4,PIN_C3,PIN_C2,PIN_C0 )
#use FIXED_IO( D_outputs=PIN_D7,PIN_D6,PIN_D5,PIN_D4,PIN_D3,PIN_D2,PIN_D1,PIN_D0 )
#use FIXED_IO( E_outputs=PIN_E2,PIN_E1,PIN_E0 )
#define LED PIN_A0
#define S1 PIN_A1
#define DISPLAY2C PIN_A4
#define DISPLAY2B PIN_A5
#define DISPLAY2D PIN_A6
#define DISPLAY2E PIN_A7
#define DISPLAY3C PIN_B0
#define DISPLAY3B PIN_B1
#define DISPLAY3A PIN_B2
#define ACTIVATESENSOR PIN_B3
#define SENSORSIGNAL PIN_B4
#define S4 PIN_B5
#define S3 PIN_B6
#define S2 PIN_B7
#define DISPLAYCOM1 PIN_C0
#define DISPLAYCOM2 PIN_C1
#define DISPLAY3F2 PIN_C2
#define DISPLAY3G2 PIN_C3
#define POWERENABLE PIN_C4
#define DISPLAY3B2 PIN_C5
#define DISPLAY3A2 PIN_C6
#define DISPLAY1BC PIN_C7
#define DISPLAY3E2 PIN_D0
#define BUZZER PIN_D1
#define DISPLAY3D2 PIN_D2
#define DISPLAY3C2 PIN_D3
#define DISPLAY3F PIN_D4
#define DISPLAY3G PIN_D5
#define DISPLAY3E PIN_D6
#define DISPLAY3D PIN_D7
#define DISPLAY2A PIN_E0
#define DISPLAY2F PIN_E1
#define DISPLAY2G PIN_E2
|
I toggle display com2 together with many other pins. All the pins are toggling except com2 |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Thu Dec 21, 2017 5:05 am |
|
|
You have not included it in the pins you are using as outputs, so it will be an input:
Code: |
#use FIXED_IO(C_outputs=PIN_C7,PIN_C6,PIN_C5,PIN_C4,PIN_C3,PIN_C2,PIN_C0 )
|
There is little point in using fixed or fast io modes. They also open you up to this sort of error. In 99% of all PIC code it's better, and simpler, to use standard IO mode and let the compiler manage TRIS stuff. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Thu Dec 21, 2017 12:25 pm |
|
|
RF-D is correct, though a bit off. I'd say 99.99999% of all the prorgams posted here do not require fixed or fast_Io().
My rule of thumb.. cut code using standard IO and test for a week. If, IF, it doesn't work THEN try fast_io. I've only truly needed it 3 or 4 times in 20 +years. All applications were 'time critical', using 4MHz xtals. |
|
|
|
|
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
|