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 support@ccsinfo.com

PIC16F18323 with pinc_c1 input

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



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PIC16F18323 with pinc_c1 input
PostPosted: Mon Dec 25, 2023 11:45 pm     Reply with quote

Hi,
I want to use pin_c1 as an input with dac function actived, but I couldn't.
Pin_c0 can use as an input, it works but C1 couldn't.

when I remove dac codes, pin_c1 can be input.

Can you say me why?

Thanks.

Here is my bacis code:

Code:

#ignore_warnings 203
#include "Library/16F18323.h"
#fuses HS,NOBROWNOUT,NOLVP,PUT,NOCPD,NOPROTECT,WDT
#use delay(crystal=20MHz, clock=20Mhz)

#include "Library/stdlib.h"
#include "Library/math.h"

#use standard_io(a)
#use standard_io(c)

//DO
#define led_pic pin_c2

//DI
#define buton1 input(pin_c0)
#define buton2 input(pin_c1)


//GENERAL
#define ON output_high
#define OFF output_low


#define flash(){ON(led_pic);delay_ms(500);OFF(led_pic);delay_ms(500);}   


#use delay(clock=20M)
void main ( )
{
   setup_spi(SPI_DISABLED);
   setup_ccp1(CCP_OFF);
   setup_ccp2(CCP_OFF);
   setup_clc1(CLC_DISABLED);
   setup_clc2(CLC_DISABLED);
   setup_dsm(DSM_DISABLED);
   setup_adc(ADC_OFF);
   
   //dac codes
   setup_adc_ports(sAN0 | DAC_CHANNEL);
   setup_dac(DAC_OUTPUT | DAC_VSS_VDD);
   dac_write(10);

   while(1)
   {
      if(input(pin_c0)) flash();
     
      if(input(pin_c1)) flash();
   }
}
zamzam23



Joined: 25 Aug 2010
Posts: 47

View user's profile Send private message

PostPosted: Tue Dec 26, 2023 12:13 am     Reply with quote

I solved.

I used dac codes like this.

Code:
   
setup_dac(DAC_OUTPUT | DAC_VSS_VDD);
set_analog_pins(PIN_A0);
Ttelmah



Joined: 11 Mar 2010
Posts: 19231

View user's profile Send private message

PostPosted: Tue Dec 26, 2023 10:11 am     Reply with quote

Well done.
The reason it didn't work, was you were using the define for the wrong thing...
You have to make sure you only use the defines where the are intended.
The DMA_CHANNEL define is to allow you to set the DMA as an input to the
ADC. So just as the FVR can be read by the ADC, so can the DMA. Doesn't
setup the pin as an analog output....
The define is for use in the set_adc_channel function, not in the ports
function.
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