Jump to content

Recommended Posts



I wonder if anyone can help.


I've bought a few PIC18F26J50's and have just upgraded to the latest version of SourceBooost (7.20), but cannot seem to get this particular PIC to work with a simple startup example (tried both the PIC's I have in case).


I've had no problem with any of the previous types of PIC's I've been using.


When I write to the PIC with my PICKIT2, the LED's I'm trying to flash light up briefly, as I would expect on writing the hex, showing me the hardware is likely ok. The loaded program just does not work.



#include <system.h>

//#include <PIC18F26J50.h>

#pragma config PLLDIV = 1 // No prescale (4 MHz oscillator input drives PLL directly)
#pragma config XINST = OFF // Disabled
#pragma config WDTEN = OFF // Disabled - Controlled by SWDTEN bit
#pragma config STVREN = OFF // Disabled
#pragma config CPUDIV = OSC1 // No CPU system clock divide
#pragma config OSC = INTOSC // INTOSC
#pragma config CP0 = OFF // Program memory is not code-protected
#pragma config T1DIG = OFF // Secondary Oscillator clock source may not be selected
#pragma config LPT1OSC = OFF // High-power operation
#pragma config FCMEN = OFF // Disabled
#pragma config IESO = OFF // Disabled
#pragma config WDTPS = 1 // 1
#pragma config DSWDTOSC = INTOSCREF // DSWDT uses INTRC
#pragma config RTCOSC = INTOSCREF // RTCC uses INTRC
#pragma config DSBOREN = OFF // Disabled
#pragma config DSWDTEN = OFF // Disabled
#pragma config DSWDTPS = 2 // 1:2,097,152 (36 minutes)
#pragma config IOL1WAY = OFF
#pragma config MSSP7B_EN = MSK7 // MSSP address mask
#pragma config WPFP = PAGE_0 // Write/Erase protect
#pragma config WPEND = PAGE_0 // Write/Erase protect
#pragma config WPCFG = OFF
#pragma config WPDIS = OFF

#pragma CLOCK_FREQ	8000000

#define LED1 portc.0
#define LED2 portc.1

void setup(void){
	// Setup internal oscillater at 8Mhz
	osccon =0b01110000; //

	// setup ports to all digital output

	// no a/d

	ancon0=0b11111111; // Digital ports
	ancon1=0b00011111; // Also digital ports
	adcon0=0b00000000; // No A/D
	adcon1=0b00000000; // No reference voltages
	wdtcon=0; // No watchdog timer

	// setup interrupts
	intcon =0b00000000; // Turn off Global, peripheral and timer 0 interrupts
	intcon2=0b00000000; // Nothing for us here
	intcon3=0b00000000; // Nothing for us here either
	pir1=0b00000000; // Actual interrupt registers - all cleared
	pir2=0b00000000; // Actual interrupt registers 2 - all cleared
	pir3=0b00000000; // Actual interrupt registers 3 - all cleared

	pie1=0b00000000; // No A/D conversion interrupt
	pie2=0b00000000; // Nothing for us here
	pie3=0b00000000; // Nothing for us here
	rcon=0b00000000; // We don't care about priorities here

void interrupt(void){

void interrupt_low(void){

void main(void){

I've been at this a while now, off and on, but with the latest SourceBoost upgrade still cant get anything working.


Any help would be greatly appreciated...

Link to post
Share on other sites

Hi Tim,


You probably have DEBUG enabled for in-circuit debugging.


I don't see anything in the .h and .tdf files to disable this in the CONFIG1L bit 7.


You may have to patch these files from copy line from file which do have it.





Link to post
Share on other sites

Hi Reynard


Thanks for that - can you give me a little more information on what I need to do, as I can't seem to make sense of the issue here.


Is it the case that my Sourceboost is not setup right?





Link to post
Share on other sites

Hi Tim,


The problem is not with you but Dave and Pavel have missed a bit out of a couple of files.


Here are some instructions on correcting the missing DEBUG config bit.


1. Open the PIC18F26J50.h file in a text editor. (RJ TextEd is one I like).

2. Open the PIC18F25J10.h file. Find the DEBUG ON/OFF pragma and copy the lines of text.

// Background Debugger Enable bit:
// #pragma config DEBUG = ON // Background debugger enabled; RB6 and RB7 are dedicated to In-Circuit Debug
// #pragma config DEBUG = OFF // Background debugger disabled; RB6 and RB7 configuredas general purpose I/O pins

3. Past the lines to the bottom of the PIC18F26J50.h and save the file.


4. Open the PIC18F26J50.tdf file (from the \config directory.

5. Open the PIC18F25J10.tdf file.

6. Find the TargetConfig DEBUG section of text and copy.

TargetConfig DEBUG
    // Background Debugger Enable bit:
    ConfigRegAddr = 0x00007FF8;
    ConfigBitMask = 0b10000000;
    ConfigSettings =
        0b00000000, "ON", "Background debugger enabled; RB6 and RB7 are dedicated to In-Circuit Debug",
        0b10000000, "OFF", "Background debugger disabled; RB6 and RB7 configuredas general purpose I/O pins";

7. Paste into PIC18F26J50 after the TargetConfig XINST section of text.

8. Change the ConfigRegAddr to 0x0000FFF8 and save the file (as it is a different device).

    ConfigRegAddr = 0x00007FF8;


    ConfigRegAddr = 0x0000FFF8;

9. In your source file add the line:

#pragma config DEBUG = OFF

Recompile and see if that works for you.


If you upgrade to a newer version of SB, check if these files have been corrected as they will be overwritten.


I think there are several files with the DEBUG config missing.





Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...