|
|
View previous topic :: View next topic |
Author |
Message |
ako Guest
|
serial comm problem with 12F675 |
Posted: Fri Sep 16, 2005 11:29 am |
|
|
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
|
|
Posted: Fri Sep 16, 2005 11:43 am |
|
|
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
|
serial comm problem with 12F675 |
Posted: Fri Sep 16, 2005 12:03 pm |
|
|
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
|
|
Posted: Fri Sep 16, 2005 12:10 pm |
|
|
Also turn off the Watchdog Timer. Change your fuses from WDT
to NOWDT. |
|
|
akokyaw
Joined: 11 Feb 2005 Posts: 24
|
|
Posted: Fri Sep 16, 2005 12:33 pm |
|
|
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
|
|
Posted: Fri Sep 16, 2005 2:32 pm |
|
|
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. |
|
|
akokyaw
Joined: 11 Feb 2005 Posts: 24
|
serial comm with 12F675 |
Posted: Fri Sep 16, 2005 5:14 pm |
|
|
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 |
|
|
|
|
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
|