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.

WOW!! been awhile but $$$

Status
Not open for further replies.
hopefully When I use the 18f43K22 I won't need to do anything special since the 18f43K22 will run on 3.3 or 5v as per data sheet but need to investigate futher
 
I've been using the 18FxxK22 family for about the last 5 years. Excellent 18F family to work with. I always use the 18Fx6K22 variant as it has a full 64K of flash ROM space. Not really any reason not to use the 6K22 variant.

For minimum setup -

Code:
#include <xc.h>
#include <stdint.h>

/* These are my standard configuration word setups for development. Set as desired for production. */

/* CONFIG1H @ 0x300001 */
#pragma config IESO=OFF,FCMEN=OFF,PRICLKEN=ON,PLLCFG=OFF,FOSC=HSMP // Fosc between 4MHz - 16MHz

/* CONFIG2L @ 0x300002 */
#pragma config BOREN=OFF,PWRTEN=ON

/* CONFIG2H @ 0x300003 */
#pragma config WDTEN=OFF

/* CONFIG4L @ 0x300006 */
#pragma config LVP=OFF,STVREN=OFF

void __interrupt(high_priority) isrH(void) {
    // high priority interrupt code goes here
}

void __interrupt(low_priority) isrL(void) {
    // low priority interrupt code goes here
}

int main(void) {
    // insert code here
    return 0;
}
 
Last edited:
Jon, I like the template idea but would change the return (0) to a while (1). Pics don't have anywhere to return to.

Mike.
 
You can place a while(1) at the end of your code yes, but you must return something at the end of an int else the compiler will complain. Your code will never hit that point but the compiler wants it there.

As far as I've read, void main no longer is supported by the ANSI C standard, but int main is, hence why I use int main instead of void main.

Technically if it did hit that part of the code, it would cause a stack overflow which should trigger a reset if you have reset on stack overflow enabled.
 
Technically it should be int but it makes no sense on processors without an operating system. Plus, not everyone reading this thread will understand the difference. :cool:

Mike.
 
For some reason Pic16 and XC8 are the only models that can have a void main... I think all the rest have to have a return.. I use MPLABC18 and always used void..

Anywho… The man uses Swordfish Basic so it matters not anyway!!!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top