nomdomokunnom
New Member
Hi guys, I'm new to using microcontrollers so I'm probably missing something obvious here, but I'm planning on trying to use a PIC16F628A to start experimenting with USB communication, but I haven't used an external oscillator before so I thought I'd give it a try. I've connected a 12MHz crystal oscillator between pins 15 and 16 (OSC1 and OSC2), and connected both pins to ground via 22pF capacitors as recommended in a diagram I found online, but my simple test program isn't working (it worked when using the internal oscillator). Anyone have any ideas what's wrong?
I have the circuit set up in a breadboard, with LEDs between Vdd and PA1 and PB4 respectively, and I'm compiling my program with BoostC++ compiler and programming it using a pickit2.
When using the internal oscillator, the port A LED stayed on while the port B LED flicked on and off, as expected; with the external oscillator, neither LED ever lit.
My source code:
Thanks in advance for any help.
I have the circuit set up in a breadboard, with LEDs between Vdd and PA1 and PB4 respectively, and I'm compiling my program with BoostC++ compiler and programming it using a pickit2.
When using the internal oscillator, the port A LED stayed on while the port B LED flicked on and off, as expected; with the external oscillator, neither LED ever lit.
My source code:
Code:
#include <system.h>
//#include "USB1.h"
#pragma DATA 0x2007, _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC
/*
class USBConnection
{
};
*/
void main()
{
clear_bit(trisa,1);
clear_bit(trisb,4);
clear_bit(porta,1);
set_bit(portb,4);
while(true)
{
clear_bit(portb,4);
for(int i=0;i<5000;i++);
set_bit(portb,4);
for(i=0;i<5000;i++);
}
}
Thanks in advance for any help.
Last edited: