PDA

View Full Version : 18f26k22 - setting fuse in program



smsteves
- 3rd October 2011, 08:27
I'm working to a project with 18f26k22 using PBP3.0.

I need internal osc 64mhz , analogic input 1-2-3-4-5-10-12, 3 output c3-c2-c1, 4 digital iput c7-c6-c5-c4.

I'm not able to configure pic, can anyone help me?

(Better in program than in .inc file)

Many Thanks
Steve

mackrackit
- 3rd October 2011, 09:48
In your PBP 3.0 directory open the directory "DEVICE_REFERENCE" and find the PIC18F26K22.INFO file, open with notepad.

Here you will find an example for setting the configs.


#CONFIG
CONFIG OSC = HS
CONFIG WDTE = ON
#ENDCONFIG

Then you will see a list of all the possible config options.

smsteves
- 3rd October 2011, 13:19
[QUOTE=mackrackit;108426]In your PBP 3.0 directory open the directory "DEVICE_REFERENCE" and find the PIC18F26K22.INFO file, open with notepad.
...

Many Thanks mackrackit, First problem solved :D

Now 2° Problem input/output/adc settings

My code :


TRISA = %00101111 ' Set PORTA to all input
TRISB = %00000011 ' Set PORTB to all input + 6 output
TRISC = %11110000 ' Set PORTC to all input + 4 output
ANSELA= %11101111
ANSELB= %00000011


ADCON1 = %10001000
ADCON2 = %10000000 ' ...and right justify result
ADCON0 = %10001001


It seems ok, But..

ADCIN report always 0..

Any Idea?

Steve

cncmachineguy
- 3rd October 2011, 14:11
Maybe if we could see your entire code, or if this is all of it, you only have the settings set up.

Dave
- 4th October 2011, 11:27
Steve, You forgot the PMD2: PERIPHERAL MODULE DISABLE REGISTER 2. It enables or disables the A/D module for the 18F26k22.
The new 18 F series use these new registers to enable and disable most all of the module functions. It's in the data sheet.....

Dave
- 4th October 2011, 11:45
Steve, also read this...


17.2.10 A/D CONVERSION PROCEDURE
This is an example procedure for using the ADC toperform an Analog-to-Digital conversion:1. Configure Port:• Disable pin output driver (See TRIS register)• Configure pin as analog2. Configure the ADC module:• Select ADC conversion clock• Configure voltage reference• Select ADC input channel• Select result format• Select acquisition delay• Turn on ADC module3. Configure ADC interrupt (optional):• Clear ADC interrupt flag• Enable ADC interrupt• Enable peripheral interrupt• Enable global interrupt(1)
4. Wait the required acquisition time(2).5. Start conversion by setting the GO/DONE bit.6. Wait for ADC conversion to complete by one ofthe following:• Polling the GO/DONE bit• Waiting for the ADC interrupt (interruptsenabled)7. Read ADC Result8. Clear the ADC interrupt flag (required if interruptis enabled).

Dave
- 4th October 2011, 11:51
Steve, I also don't see where you are setting the A/D reference voltage source...

smsteves
- 4th October 2011, 13:09
Hi Dave,


I'll test as soon as possible following your advices



Many thanks for your help...
Steves