An Advanced PIC Laboratory for less than a tank of gas

Junebug PIC Laboratory

PICkit 2 Compatible Programmer / Debugger

Advanced 18F1320 Tutor / Experimenter

Junebug is a combination USB PICKit2 SE* PIC development tool and Enhanced 18F Tutor

Junebug Kit $49

So you want enter the exciting world of microcontrollers, then this kit was designed for you.

Here's the Junebug Assembly Manual be sure to check for new update, currently April 20, 2008

  • USB based PICKit2 compatible PIC Programmer / debugger for many 16F & 18F PICs

  • Supports both MPLAB IDE 8.x and standalone PICKit2 software

  • Onboard tutor support for either 16F88 or 18F1320

  • USB powered programmer & tutor, can supply up to 100ma @ 5VDC to your target project

  • 3.3V support is possible by adding a pair of clamp diodes to the PGC & PGD pins

* the SE (Student Edition) does not have a programmable 2.5V - 5V VDD or the internal EEPROMs found on the genuine Microchip PICkit2.

Recommend reading

Microprocessors: From Assembly Language to C Using the PIC18Fxx2
by Reese, Robert B.

Originally written as Mississippi State University course material at 664 pages (plus a CD ROM)

Mr Reese's website contains the source code HiTechC (in the book) converted to C18 and the well written lecture notes & quiz available for free download.

 

Swordfish BASIC

Swordfish BASIC is an excellent Structured Modular BASIC compiler for the 18Fxxx series of PIC microcontrollers. The developers have a free Student Edition, download it from the Swordfish website. It has a very generous limit of 256 bytes of RAM but no limit on the ROM size.

It's a powerful full featured language, if you have a Junebug or Mongoose we've got a couple of modules for it, copy the modules into Swordfish Library directory.

JUNEBUG.BAS the Junebug module 0.93beta supports the LEDs and pushbuttons.

MONGOOSE.BAS  the Mongoose module also in beta, easy PWM Motor control.

Here's a simple Swordfish BASIC SE program that flashes Junebugs LEDs in sequence.

// Name : BLINK_1.BAS
Device = 18F1320
Clock = 4
           // 4MHz clock
Include
"junebug.bas"
Dim
Count As Byte
OSCCON = $62  
      // select 4MHz internal clock
ADCON1 = %11110101   // digital I/O except RA1 & RA3
While True
    For
Count = 0 To 6
        LED(Count)
  // light LED(1..6) or none LED(0)
        DelayMS(300) // delay in 1000s of a second
    Next
Wend
                // repeat forever
End

And here's a reaction time game called Ready Steady GO!

//  LEDs 3,2,1 countdown, press button #1 as soon as LED 1 is lit
//  DIP Switch #4 must be on to see results using PICkit2 UART Tool

Device
= 18F1320
Clock
= 8
// 8MHz clock
Include "junebug.bas"
Include "convert.bas"
Include "usart.bas"
Dim Qualify, Temp As Byte
Dim
Time As String
' total time in us
Interrupt ButtonPress()
   T0CON.7 = 0
' stop the timer
   If Qualify = 0
     Then
      
Write(
" Too Soon! You have to wait till LED #1 is lit.",13,10)
       LED(6)
     Else
      
Temp = TMR0L
' loads TMR0H
       Time = DecToStr(((TMR0H*256)+Temp)*16,6)
       Write(
" Your time was 0.",Time," Seconds.",13,10)
       LED(4)
     EndIf
     
INTCON.4 = 0
 
    While true
    Wend
End Interrupt
OSCCON = $72
// 8 MHz clock
SetBaudrate(br9600)
INTCON2.7 = 0
' weak pullups on
INTCON.1 = 0 ' INT0IF
INTCON.4 = 1
' INT0IE
INTCON2.6 =0 ' INTEDG0 falling edge trigger
ADCON1 = %11110101
   Write(
"When LED 1 lights press button #1.",13,10)
   Qualify = 0
   T0CON = $04
' 1/32 prescaler on timer 0, 16 bit mode
   TMR0L = 0 ' clear the timer
   TMR0H = 0
LED(3)
' Ready
   DelayMS(1000)
   INTCON.1 = 0
' clear the interrupt flag
   Enable(ButtonPress)
LED(2)
' Steady
   DelayMS(500)
   Qualify = 1
' don't disqualify yourself by pressing too early
   T0CON.7 = 1 ' start the timer
LED(1) ' GO
   DelayMS(1000) ' 1 second timeout
   INTCON.4 = 0 ' too slow disable interrupt
LED(5)
   Write(
" Too Slow, press RESET to try again."
,13,10)
While true
Wend
End