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

serial comm problem with 12F675

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







serial comm problem with 12F675
PostPosted: Fri Sep 16, 2005 11:29 am     Reply with quote

Hi,
I have some problem with seial comm using 12F675. I tried sample program as follow:
Code:

#include <12F675.h>
#fuses HS,WDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A4)

main()
{
   while(1)
   {
      printf("\r\nRunning voltage test...\r\n\n");
      delay_ms(500);
   }
}

I used 20MHz osc and connected to GP5. GP3 as Tx and GP4 as Rx but I cannot get response on "Serial input/output monitor" (siow). Any help would be appreciated.

Thanks,
ako
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 11:43 am     Reply with quote

Pin GP3 is input only. It can't be used as an output pin.
Before you assign pins, look in the 12F675 data sheet, in the
Device Overview section. That section has a chart of the pins
and it shows all the possible ways the pins can be configured.

For example, for pin GP3 it says:
Input port w/ interrupt-on-change


Also, if you do want to use GP3 for an input, you need to disable
the MCLR function on that pin. Use the NOMCLR fuse to do this.
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

serial comm problem with 12F675
PostPosted: Fri Sep 16, 2005 12:03 pm     Reply with quote

Hi,
Thank for fast response. I changed my program as you suggested:
Code:

#include <12F675.h>
#fuses HS,WDT,NOPROTECT, NOMCLR
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A4, rcv=PIN_A3)

main()
{
   while(1)
   {
      printf("\r\nRunning voltage test...\r\n\n");
      delay_ms(500);
   }
}

But, the problem is still exist. I used USB programmer (kit 128) and ccs 3227. I have changed new 12F675.

Thanks,
ako
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 12:10 pm     Reply with quote

Also turn off the Watchdog Timer. Change your fuses from WDT
to NOWDT.
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 12:33 pm     Reply with quote

Hi,
I changed the program as follow:

Code:

include <12F675.h>
#fuses HS,NOWDT,NOPROTECT, NOMCLR
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A4, rcv=PIN_A3)


void init()
{
   set_tris_a( 0b11101111 ); // set GP1 output, all other inputs
   setup_comparator( NC_NC_NC_NC ); // disable comparators
   setup_adc_ports( NO_ANALOGS ); // disable analog inputs
   setup_adc( ADC_OFF ); // disable A2D
   SETUP_TIMER_1(T1_DISABLED);  //disable T1G (GP4)
}
main()
{
   init();
   while ( TRUE ) // forever loop
   {
      printf("\r\nRunning voltage test...\r\n\n");
      delay_ms(500);
   }
}



Still problem, Anyway, thank a lot for your support

Thanks,
ako
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 2:32 pm     Reply with quote

Are you using a 20MHz oscillator, or 20MHz crystal? Your fuses are set like you're using a 20MHz crystal (HS), yet you are using GP4 as an output.

If you are using a 20MHz oscillator, you need the EC fuse not the HS one.

If you are using a 20MHz crystal you need the HS fuse, but you can't use GP4 for IO.

It's all in the datasheet. Rolling Eyes
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

serial comm with 12F675
PostPosted: Fri Sep 16, 2005 5:14 pm     Reply with quote

Thank man,
It is working, man. I have changed the code as

Code:
#include <12F675.h>
//#fuses HS,NOWDT,NOPROTECT, NOMCLR
#fuses EC_IO, NOWDT, NOCPD, NOPROTECT, NOMCLR, NOPUT, BROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A1, rcv=PIN_A2)


void init()
{
   //set_tris_a( 0b11101111 ); // set GP1 output, all other inputs
   setup_comparator( NC_NC_NC_NC ); // disable comparators
   setup_adc_ports( NO_ANALOGS ); // disable analog inputs
   setup_adc( ADC_OFF ); // disable A2D
   SETUP_TIMER_1(T1_DISABLED);  //disable T1G (GP4)
}
main()
{
   init();
   while ( TRUE ) // forever loop
   {
      printf("\r\nRunning voltage test...\r\n\n");
      delay_ms(500);
   }
}


ako Idea
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