|
|
View previous topic :: View next topic |
Author |
Message |
obi1 Guest
|
Problem with PIC12F683 |
Posted: Mon Nov 07, 2005 5:51 pm |
|
|
I'm having problem using PCWH Version 3.206 with PIC12F683. I'm doing a simple program to test the pic, but they are not working. Can anyone please tell me what is wrong with this code?
#include <12F683.h>
#device ADC=10//to define size of AD Channel
#fuses INTRC_IO, NOWDT,NOPROTECT,NOCPD,NOBROWNOUT,NOMCLR,NOPUT,NOIESO,NOFCMEN
#use delay(clock=4000000)
//Setup Software serial communicationl
#use rs232(baud=9600, xmit=PIN_A5,BITS=8,INVERT)
void main(){
while(1)
{
output_high(PIN_A2);
DELAY_MS(500);
output_low(PIN_A2);
DELAY_MS(500);
}
}
I'm sure that it's not the hardware problem. There is no output at Pin a2 at all. Please tell me how to fix this.
Thank you
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 07, 2005 7:00 pm |
|
|
Quote: |
I'm having problem using PCWH Version 3.206 with PIC12F683.
I'm doing a simple program to test the pic, but they are not working |
Your version of the compiler doesn't setup the i/o ports for digital i/o
correctly. To fix the problem, you need to add the lines shown in
bold below, to your program.
Quote: | #include <12F683.h>
#device ADC=10//to define size of AD Channel
#fuses INTRC_IO, NOWDT,NOPROTECT,NOCPD,NOBROWNOUT,NOMCLR,NOPUT,NOIESO,NOFCMEN
#use delay(clock=4000000)
//Setup Software serial communicationl
#use rs232(baud=9600, xmit=PIN_A5,BITS=8,INVERT)
// Define register addresses so we can write to them directly.
#byte CMCON0 = 0x19
#byte ADCON0 = 0x1F
#byte ANSEL = 0x9F
void main()
{
CMCON0 = 7; // Turn off the comparators
ADCON0 = 0; // Set all i/o pins to digital
ANSEL = 0; // Turn off the A/D converter
while(1)
{
output_high(PIN_A2);
DELAY_MS(500);
output_low(PIN_A2);
DELAY_MS(500);
}
} |
|
|
|
obi Guest
|
|
Posted: Tue Nov 08, 2005 10:17 am |
|
|
Thank you for your help. It's working!!! |
|
|
|
|
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
|