PIC24F

Started by Paul Laverick April 16, 2009
Hi all,

I have been researching the PIC24F, a 16 Bit PIC, and found that its voltage is 1.8V-3.6V. Well that's not to bad, get a 3.3V regulator or something, but then then i started thinking about LCDs etc, how do you go about interfacing them as they run on 5V? Has anyone used these before?

Cheers,
Paul
----- Original Message -----
From: Paul Laverick
To: p...
Sent: Thursday, April 16, 2009 5:26 PM
Subject: [piclist] PIC24F

> get a 3.3V regulator or something, but then
> then i started thinking about LCDs etc

Most LCDs and other circuits will work fine with 3.3V. Some LCDs do get a
little slow so you need to acount for that.

The place you pay is in analog. A/D's don't work nearly as well at the
lower voltage. That is the only reason why they keep the 30F around.

By the way, if you want 5 volts, the 30F is practically the same chip. Of
course it has the DSP engine, but that is sort of an add on, and doesn't
change the was the basic chip works (darn cool add-on tho). It also has
EEPROM which is lacking in the 24F, and it has more capable A/D. But it is
lacking the ability to reassign pins which is a really cool feature of the
24, and it is quite a bit more power hungry.

Also keep in mind:
24F - 16 MIPS
30F - 30 MIPS
24H - 40 MIPS

--McD

I had a look into the 30F and got a little nervous, so was hoping to start on a simple 16 bit, but then again, if I'm only playing, then 3.3V is not a problem
The structure of the 30F seemed different to the 24F but i suppose i should look into it more.
I don't really think i need a 16 Bit chip, but i am keen to experiment

Cheers!
Paul
From: John J. McDonough, WB8RCR
Sent: Friday, April 17, 2009 12:41 AM
To: p...
Subject: [piclist] PIC24F

----- Original Message -----
From: Paul Laverick
To: p...
Sent: Thursday, April 16, 2009 5:26 PM
Subject: [piclist] PIC24F

> get a 3.3V regulator or something, but then
> then i started thinking about LCDs etc

Most LCDs and other circuits will work fine with 3.3V. Some LCDs do get a
little slow so you need to acount for that.

The place you pay is in analog. A/D's don't work nearly as well at the
lower voltage. That is the only reason why they keep the 30F around.

By the way, if you want 5 volts, the 30F is practically the same chip. Of
course it has the DSP engine, but that is sort of an add on, and doesn't
change the was the basic chip works (darn cool add-on tho). It also has
EEPROM which is lacking in the 24F, and it has more capable A/D. But it is
lacking the ability to reassign pins which is a really cool feature of the
24, and it is quite a bit more power hungry.

Also keep in mind:
24F - 16 MIPS
30F - 30 MIPS
24H - 40 MIPS

--McD
This is a VERY lightweight quickstart guide to writing one's first PIC24 assembly language program. It assumes you're familiar with Microchip microcontrollers and the MPLAB IDE (Integrated Development Environment).

Material you have to read::
1.) Datasheet of your PIC24 microcontroller.
- I used a PIC24HJ12GP201
- At the very least go through:
- CPU
- Memory Organization
- Flash Program Memory
- Oscillator Configuration
- I/O Ports
- Eventually you'll wind up reading most of the datasheet
but this is a good start.

2.) Read and/or download the PIC24F or PIC24H Family Reference Manual
- You can probably defer much of the FRM reading for now.
- http://www.microchip.com
- "Products"
- "16-Bit PIC24 MCUs & dsPIC DSCs"
- "Reference Manuals"
- Pick the manual for your family.
- It's a listing of chapters (each is a .PDF file).

3.) MPLAB IDE "Help"
- Topics
- MPLAB ASM30
- MPLAB Assembler for PIC24 MCUs and dsPIC DSCs
- Go through:
- Overview (especially Input/Output Files)
- Syntax
- Expression Syntax and Operation
- Expressions
- Operators
- Special Operators
- Symbols (All Subtopics)
- Directives (All Subtopics)

4.) My circuit is as follows:
- PIC24HJ12GP201
- Vdd (pin18) = 3.3V.
- Vss (pins17 & 13) = 0V (GND).
- VddCore ( pin14) = 1uF tantulum electrolytic cap to GND.
- 10K Ohm resistor from pin1 (MCLR_L) to Vdd/3.3V.
- 150 Ohm resistor from pin4 (RB0) to LED anode.
- 150 Ohm resistor from pin5 (RB1) to LED anode.
- Both LED cathodes to GND.
- 0.100" pitch header for PICkit2/3 or ICD2/3 wired as follows:
- MCLR_L/Vpp (PIC24HJ12GP201 pin1 / connector pin1)
- Vdd (PIC24HJ12GP201 pin18 / connector pin2)
- GND (PIC24HJ12GP201 pins17 & 13 / connector pin3)
- PGD2 (PIC24HJ12GP201 pin2 / connector pin4)
- PGC2 (PIC24HJ12GP201 pin3 / connector pin5)
- It's up to you to get these 5 connections to your
debugger. I used a flying leads-to-MMJ pigtail
to connect to my ICD2.
- External power supply providing 3.3V.

5.) Before you connect to your hardware:
- MAKE SURE YOU DO NOT POWER THE TARGET FROM YOUR DEBUGGER.
(check your debugger settings in MPLAB IDE BEFORE
connecting to the hardware)
- My ICD2 would supply 5V which would be bad for the PIC24H.

6.) Create an MPLAB IDE project using the Project Wizard.

7.) Set the Configuration-Bits in MPLAB IDE as follows:
- Oscillator Mode
- Set to: Internal Fast RC (FRC divide by 16)
- Watchdog Timer Enable
- Set to: Disable
- OSC0/OSC2 Pin Function
- Set to: OSC0 pin has clock out function
- Internal EXternal Switch Over Mode
- Set to: Startup with user-selected oscillator
- Clock Switching and Monitor
- Set to: Sw Disabled, Mon Disabled

8.) Add files to your project:
- Add the linker script file: p24HJ12GP201
- It can be found at: \Microchip\MPLAB\MPLAB ASM30 Suite\Support\PIC24H\gld\p24HJ12GP201.gld
- Add the device include file: p24HJ12GP201.inc
- It can be found at: \Microchip\MPLAB\MPLAB ASM30 Suite\Support\PIC24H\inc\p24HJ12GP201.inc
- Add your source file: .s
- My example is below.

If all goes well, the two LEDs will go back and forth from ON-OFF to OFF-ON a little quicker than once-per-second.

My source code:
--------------

.title " Sample dsPIC Assembler Source Code"
.sbttl " LED Toggle"

.include "p24HJ12GP201.inc"
.text
.global __reset
__reset:
mov #0x0a00,W8
mov W8,SPLIM
mov #0x0980,W15
mov #0xfc,W4
mov W4,TRISB

mloop: mov #0x02,W5
mov W5,PORTB
call delay

mov #0x01,W5
mov W5,PORTB
call delay

bra mloop

delay: mov #0x7fff,W6
dloop: dec W6,W6
cp0 W6
bra NZ,dloop
return
.end

I didn't have to do anything special to declare PGD2 & PGC2, the PIC just knew how to deal with those connections. I claim nothing on this post except that I got from zero to running a very simple PIC24 assembly language program.

The datasheet has register maps and a terse overview of the instruction set. One should realize that the PIC24 family has many more intricacies in instruction operation, pipelining, addressing modes, etc. So RTFP (read the fine print)!

>From here, there tons of features to explore and master. You could probably get there quicker with C language programming. I'm just a dinosaur who likes to be able to do assembly language as a basis first. I hopes this helps and isn't too full of errors.

Coop, AA1WW