|
|
View previous topic :: View next topic |
Author |
Message |
thefloyd
Joined: 02 Sep 2009 Posts: 46
|
PIC18F46K22 issues? |
Posted: Wed Sep 12, 2012 6:26 pm |
|
|
For the life of me I can't seem to get my PIC18F46K22s to work. I've tried a couple.
simple example:
#include <18f46k22test.h>
void main()
{
setup_oscillator(OSC_4MHZ|OSC_INTRC);
//Example blinking LED program
while(true)
{
output_low(LED);
delay_ms(DELAY);
output_high(LED);
delay_ms(DELAY);
}
}
.h file:
#include <18F46K22.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC //Internal RC Osc
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(int=4000000)
#define LED PIN_A0
#define DELAY 1000
I've fiddled with everything from 64mhz down to 4mhz, changing the setup_oscillator() and #use delay lines as appropriate. Something is clearly happening, because I get as far as executing output_low (if I swap the order and set output_high first I get that far as well). As soon as I hit the delay, it's off to la-la land. I'm guessing the pic is oscillating at something like 32khz or something like that, whereas the delays are all timed for Xmhz.
why? Am I insane? |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Sep 12, 2012 6:47 pm |
|
|
1- learn to use the 'code' icon
2- here is a devel/ test setup that works for me
Code: |
#include <18f46k22.h>
#Fuses INTRC_IO,NOPLLEN,PRIMARY_ON,NOFCMEN,NOIESO,PUT,
#Fuses BROWNOUT,BORV29,NOWDT,
#Fuses CCP2C1,NOPBADEN,CCP3B5,
#Fuses NOHFOFST,TIMER3B5,NOMCLR,
#Fuses NOSTVREN,NOLVP,NOXINST,NODEBUG
#Fuses NOPROTECT,NOCPB,NOCPD,NOWRT,NOWRTC
#Fuses NOWRTB,NOWRTD,NOEBTR,NOEBTRB
#use delay( clock=8000000,INTERNAL ) // clock changed to 80000
#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, ERRORS )
|
|
|
|
thefloyd
Joined: 02 Sep 2009 Posts: 46
|
|
Posted: Wed Sep 12, 2012 7:05 pm |
|
|
Thanks, that definitely works. I'm able to blink an LED at 8mhz using that setup.
I'll fiddle with the fuses and delay to see if I can get the PLL working and the higher clock speeds. |
|
|
|
|
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
|