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

PIC12F1822 pin assignment question

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



Joined: 18 Aug 2011
Posts: 8

View user's profile Send private message

PIC12F1822 pin assignment question
PostPosted: Thu Aug 25, 2011 12:03 pm     Reply with quote

The Tx and Rx pins can be assigned to other pins (the default should be A0 and A1). I can get the serial port to work on A4 and A5 but not the default pins A0 and A1. What am I missing?
running PCM version 4.125
Code:

#include <12F1822.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(internal=32000000)
//#use rs232(baud=19200, UART1, xmit= PIN_A0, rcv=PIN_A1)
#use rs232(baud=19200, UART1, xmit= PIN_A4, rcv=PIN_A5)

#include <PIC12F1822.h>

int16 ms_counter = 0;
int1 flag = 0;

void main()
{
   setup_adc_ports(sAN0);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);

  while(1)
  {
  if(ms_counter >= 976)
  {
    ms_counter = 0;
        if(flag == 0)
        {
         output_high(PIN_A2);
         flag = 1;
        }
        else
        {
         output_low(PIN_A2);
         flag = 0;
        }
     printf("counter print\r\n");
  }

   }//while 
}//main


//8mhz clock divide by 32 and over flow of 256 = 1.024ms
//counter = 976 to get one second timer
#int_TIMER0
void TIMER0_isr(void)
{
ms_counter++;
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 25, 2011 1:16 pm     Reply with quote

I stripped your test program down to make it much more simple.
Try this transmission and Echo test. See if it works.
Code:

#include <12F1822.h>
#FUSES NOWDT       
#FUSES INTRC_IO   
#FUSES NOBROWNOUT 
#FUSES NOIESO
#FUSES NOFCMEN 
#FUSES NOLVP 

#use delay(clock=4M)
#use rs232(baud=19200, UART1)

//=======================================
void main()
{
char c;

printf("Start: ");

while(1)
  {
   c = getc(); // Get char from PC
   putc(c);    // Send it back to the PC
  }

}
dave_s



Joined: 18 Aug 2011
Posts: 8

View user's profile Send private message

PIC12F1822 pin assignment question
PostPosted: Fri Aug 26, 2011 5:49 am     Reply with quote

The simple version still not working on A0 and A1.
Replaced chip with same results!
How can I read the APFCON register to see if it has been changed from default?
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Aug 26, 2011 6:27 am     Reply with quote

I'm using the 12F1822's bigger brother, the 16F1823 as a 4 channel remote ADC widget. I found if you specify the pins, it'll use a software UART, so don't use xmit= PIN_A0, rcv=PIN_A1 etc. Instead to select which pins use UART1 or UART2. In your case try UART2.

CCS documentation didn't help with this. I found it by trial and error. Mad

RF Developer
dave_s



Joined: 18 Aug 2011
Posts: 8

View user's profile Send private message

PostPosted: Fri Aug 26, 2011 6:36 am     Reply with quote

Thank you RF_Developer that was it!
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