Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Voltage to frequency converter with PIC

Status
Not open for further replies.
Got 18F242 today !

Need some help with configuration statement(s) - equvalent to
__config 0x3d3a for 16F870

I see qute a few registers there...
 
Avoid using "magic numbers" when specifying constants.

Code:
     LIST         P = PIC18F242, F = INHX32, R = DEC
     INCLUDE      "P18F242.INC"

 __CONFIG _CONFIG1H, _HSPLL_OSC_1H
 __CONFIG _CONFIG2L, _BOR_OFF_2L&_PWRT_OFF_2L
 __CONFIG _CONFIG2H, _WDT_OFF_2H
 __CONFIG _CONFIG3H, _CCP2MX_ON_3H
 __CONFIG _CONFIG4L, _STVR_ON_4L&_LVP_OFF_4L&_DEBUG_OFF_4L
 __CONFIG _CONFIG5L, _CP0_OFF_5L&_CP1_OFF_5L&_CP2_OFF_5L&_CP3_OFF_5L
 __CONFIG _CONFIG5H, _CPB_OFF_5H&_CPD_OFF_5H
 __CONFIG _CONFIG6L, _WRT0_OFF_6L&_WRT1_OFF_6L&_WRT2_OFF_6L&_WRT3_OFF_6L
 __CONFIG _CONFIG6H, _WRTC_OFF_6H&_WRTB_OFF_6H&_WRTD_OFF_6H
 __CONFIG _CONFIG7L, _EBTR0_OFF_7L&_EBTR1_OFF_7L&_EBTR2_OFF_7L&_EBTR3_OFF_7L
 __CONFIG _CONFIG7H, _EBTRB_OFF_7H
 
Thanks,
This configuration is a little different than 16F... :lol:

Last night I got 18F242 interrupt program working - no analog section yet.
I am using 20MHz resonator for now.
Looking at the scope I should be able to have room for main program at 50KHZ. will do more tests and post results.
 
Almost forgot. The above configuration applies to a 4X HS PLL oscillator (i.e. 40Mhz).
 
I saw this,
I was using HS type when I set conf mannualy...
I just don't has 40MHz crystal yet.

I plugged 18F242 to the same breadboard circuit i have for 16F870 and it worked.
I will try to post scope snapshots tonight.
So far I got divider as low as 000C with 1:2 timer clock.
This gives me 50KHz and about 15-18 clocks in the main program to handle analog inputs. The way I am doing this:
I am looping the main program and toggling another port:
Code:
LOOP01:
negf LATB,0
GOTO LOOP01
I am using port C for pulse train generation and port B for diagnostics.
This loop takes 3 clocks or 600ns on the scope, so I can see interrupts on 2 channel oscilloscope.

600ns/3=200ns => 5 MHz * 4 => 20MHz crystal...
 
Just a quick update:
I still can't run 18F242 at 40MHZ - I don't have 10MHZ Crystal yet.
It actually work just fine with 12MHZ Crystal (48MHZ), but I don't want to overclock it yet.

So I am running it at 20MHZ (HS mode) for now and spent some time on analog conversion.
I am not doing sampling/avaraging yet - just simple read.
Presets are taken form the table - 1024 DW values generated in excel and pasted into asm program.

Works fine but I did no extensive testing yet. I will post code in a couple days.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top