View previous topic :: View next topic |
Author |
Message |
billy
Joined: 16 Aug 2013 Posts: 2
|
Internal Oscillator 12F615 |
Posted: Sun Aug 18, 2013 11:13 pm |
|
|
Good day,
I am new with the software and a student. I need some advice on the setup of the internal oscillator. How do I know if the internal oscillator are running when using the PIC12F615? I have done the setup, but it seems that my processor is not running.
See my code:
Code: |
#include <12F615.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES IOSC8 //INTOSC speed 8 MHz
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPUT //No Power Up Timer
#use delay(clock=8000000)
void main()
{
setup_adc_ports(sAN3|VSS_Vref);
setup_adc(ADC_CLOCK_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_16,255,1);
setup_comparator(NC_NC_NC_NC);
|
Hope somebody can assist me.
Billy. |
|
|
stinky
Joined: 05 Mar 2012 Posts: 99 Location: Central Illinois
|
|
Posted: Sun Aug 18, 2013 11:46 pm |
|
|
How do you know it's not working? |
|
|
billy
Joined: 16 Aug 2013 Posts: 2
|
|
Posted: Mon Aug 19, 2013 12:44 am |
|
|
Stinky,
My code is quite simple. made an output high for LED. After programming the pic, put in my development board. LED is not on when powering up.
If I simulate the program in proteus, the program is working. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Aug 19, 2013 1:12 am |
|
|
The point is that what you post does not show the LED code.
Anyway some comments inline:
Code: |
#include <12F615.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES IOSC8 //INTOSC speed 8 MHz
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPUT //No Power Up Timer
#use delay(clock=8000000)
#define LED PIN_xx //Select to suit your LED
void main()
{
setup_adc_ports(sAN3|VSS_Vref);
setup_adc(ADC_CLOCK_INTERNAL);
//Read the data sheet. Is this a legal ADC clock at this CPU clock....
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_16,255,1);
setup_comparator(NC_NC_NC_NC);
do
{
output_toggle(LED);
delay_ms(1000);
} while (TRUE);
}
//This shows flashing an LED
//Things that would stop it working:
//1) Choosing pin A3 for the LED - this is _input only_.
//2) Not having a suitable current limiting resistor on the LED
//If the LED is wired directly, it'll short out the PIC, odds are it'll reset
//and nothing will apparently happen.
//3) Choosing pin A4 for the LED. This is AN3, which you are setting
//as an analog input.
|
Read the inline comments.
Best Wishes |
|
|
|