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.

getting started with junebug and mongoose.

Status
Not open for further replies.

yohanevindra

New Member
i have learnt PICs in uni, so i know how to use the PICDEM2 board and program, or at least can refresh my memory...

im having trouble tho getting started with junebug. first of all, in my MPLAB IDE, there is no option to select PICkit2 as the programmer or debugger. and then, where do i set the DIP switches when I want to use junebug as a PICkit2?I'm guessin to program the mongoose you use it in PICkit2 mode...also, how do you make the ICSP connections?I have the cable...

then, if i want to experiment with the PIC on the junebug board and write code for that, how do i set it up and what do i do?

thanks in advance.
 
I think in the more recent versions of MPLAB picKit2 support is an option you need to check during installation.

To program the onboard PIC18F1320 you must have switches 1,2, and 3 on. To program other targets using the ICSP connector turn these switches off.
 
ohhhh...so i might have to reinstall MPLAB then??bummer...yeah..i tihnk you're right about selecting it in the installing process.

so to program the junebug it self switches 1 2 3 are ON and then to program a target using the junebug, all switches are OFF?
 
ok.so since i'm coming back to PICs after sometime, thought i'll try the simplest of programs..

Code:
#include <stdio.h>
#include  <p18f1320.h>

void main ()
{
	PORTA = 0x00;
	
	while(1)
	{
		
		PORTA = 0xFF;
	}
}

the PICkit2 detects the PIC18f1320, and builds successfully and programs the code successfully too..but then, instead of lighting up all the LEDs nly one is faintly glowing and that too never stops..have i screwed up the board?
ohh.and since im testing the board, DIP switches 1,2,3 are ON.
 
There are many things wrong with this program. It is too simple.

You have not set the processor configuration using
#pragma config

You did not set TRISA so we do not know if the port pins are input or output.

The LEDs on the Junebug are charlieplex. Check [/FONT][/B]for more info.

I would put this line first incase anything that followed it required processor specific info.
#include <p18f1320.h>

Take a look at this tutorial
 
Last edited:
This should get you going with the LEDs, the infamous night rider effect,
Code:
#include <p18f1320.h>
#pragma config WDT = OFF, LVP = OFF, OSC = INTIO2
#include "delays.h"

void LED(char num);

void main(){
char i;
    OSCCON=0x60;                //Osc=4MHz
    ADCON1=0x7f;                //All digital
    while(1){                   //loop forever
        for(i=1;i<7;i++){
            LED(i);
            Delay1KTCYx(100);
        }
        for(i=5;i>1;i--){
            LED(i);
            Delay1KTCYx(100);
        }
    }
}


void LED(char num){
    TRISA|=0b11000001;              //A0,A1 & A2  input;    
    LATA &=0b00111110;
    switch(num){
        case 1:
            TRISA&=0b10111110;
            LATA |=0b00000001;
            break;
        case 2:
            TRISA&=0b10111110;
            LATA |=0b01000000;
            break;
        case 3:
            TRISA&=0b00111111;
            LATA |=0b01000000;
            break;
        case 4:
            TRISA&=0b00111111;
            LATA |=0b10000000;
            break;
        case 5:
            TRISA&=0b01111110;
            LATA |=0b10000000;
            break;
        case 6:
            TRISA&=0b01111110;
            LATA |=0b00000001;
            break;            
    }
}

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top