Searching \ for 'Example' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=example
Search entire site for: 'Example'.

Truncated match.
PICList Thread
'Example'
2000\03\07@132817 by Steve Horvath

flavicon
face
Hello
I am fairly new to PIC programming, but have a fair bit of experience form
school involving the Intel 8031.  I was wondering if someone could write a
quick program (2 minute job) to do the fallowing on a 16f84, so that I
could learn about these functions by doing them:
-push W onto a stack, and pop W off of the stack
- input from port A to W when there is an interrupt
- have a 10ms delay using the timer
- output to pb.0 through pb.4 after the interrupt
- have a 1 second timer using loops, and have the output (port B) blink on
and off every second thereafter.


oh, and could someone tell em the difference between portA and trisA?

thanks for your help, this should pretty well be what I need to get
everything straightened out.

Steve Horvath

2000\03\07@143227 by Andre Abelian

picon face
Steve,

In the school did you do all that in 2 minutes or in 2 years?

Andre



{Quote hidden}

2000\03\07@153123 by M. Adam Davis

flavicon
face
There are only 35 instructions to learn on this PIC.  The easiest way to learn
how to use the PIC is to read the data sheets, and jump in.  There are some
books which can help you do so, and many web sites which will also help.

See my links to such resources at
http://www.ubasics.com/adam/pic/

I can help a little bit here with your questions:

Steve Horvath wrote:
>
> Hello
> I am fairly new to PIC programming, but have a fair bit of experience form
> school involving the Intel 8031.  I was wondering if someone could write a
> quick program (2 minute job) to do the fallowing on a 16f84, so that I
> could learn about these functions by doing them:

First, the architecture is very different between these two mcus.  You'll find
yourself referring to the datasheet as you program.

> -push W onto a stack, and pop W off of the stack

There really is no direct analogy in the PIC for your stack.  You have no access
to the stack in the '84.  If you want to program this way, then you'll need to
create a software stack (which, for most things, is inefficient.  It's just a
different architechture, and a different way of thinking)

> - input from port A to W when there is an interrupt

org     4
       (Save status registers if needed here (no point in saving W ;-) )
       movf PORTA, W
       (restore status registers if needed here)
       RETFIE

> - have a 10ms delay using the timer
> - output to pb.0 through pb.4 after the interrupt
> - have a 1 second timer using loops, and have the output (port B) blink on
> and off every second thereafter.
>
> oh, and could someone tell em the difference between portA and trisA?

Each i/o pin on the PIC can be an input, or an output.  TRISA defines whether
each pin in portA is input(1) or output(0).  PORTA represents the actual status
of PORTA.  If you are driving all pins low, but an external circuit is driving
them all high, then PORTA will read all high (ie, the real state, not the state
the PIC is trying to keep it it)

There are other examples out there which do all of what you are asking.  Check
my links above, and then start asking more specific questions.

I hope this helps!

-Adam

2000\03\07@163534 by Thomas C. Sefranek

face picon face
Steve Horvath wrote:

> Hello
> I am fairly new to PIC programming, but have a fair bit of experience form
> school involving the Intel 8031.  I was wondering if someone could write a
> quick program (2 minute job) to do the fallowing on a 16f84, so that I

Let me get this straight...
You want to LEARN by having someone write the code for you?
And you want it done in 2 Minutes?
What wrong with this picture?

{Quote hidden}

--
 *
 |  __O    Thomas C. Sefranek  spam_OUTtcsTakeThisOuTspamcmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 Mhz

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

2000\03\07@170524 by jona ATLAS
flavicon
face
Steve,
If you are interested, I can send you a free book "Understanding &
Programming the PIC16C84-a beginner4s tutorial, writed by Jim Brown). It4s
about 25 A4 pages, now in HTML format, including commented code examples. I
found it very usefull. It4s approx 25Kb zipped file. Just leave an Email

JONA

2000\03\07@173045 by Peter Vincent

flavicon
face
sigh..... here we go again have a look at the DATA SHEET it is available
FREE from microchip

----- Original Message -----
From: "Steve Horvath" <.....steveKILLspamspam@spam@ZORT.ON.CA>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: Tuesday, March 07, 2000 6:21 PM
Subject: Example


{Quote hidden}

2000\03\07@174050 by andy howard

flavicon
face
> Steve Horvath wrote:

> > school involving the Intel 8031.  I was wondering if someone could
write a
{Quote hidden}

blink on
> > and off every second thereafter.

And doesn't that look *exactly* like a specification handed out for a
school project?













.

2000\03\07@175931 by Rob

picon face
----- Original Message -----
From: andy howard <.....musicaKILLspamspam.....UKONLINE.CO.UK>
To: <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU>
Sent: Tuesday, March 07, 2000 5:23 PM
Subject: Re: Example


{Quote hidden}

HAHAH!! Actually, this is how I got my first project off the ground! Its
much quicker and more useful than one might imagine. I learned more by
someone writing it for me and me troubleshooting the code than I EVER would
have learned alone given twice the time.. But, OTOH, I paid the guy fairly
well to do it ($200) to spend an hour coding and maybe another more to be my
coder/teacher.

Rob

2000\03\07@181806 by Gennette Bruce

flavicon
face
       -----Original Message-----
       From:   M. Adam Davis [SMTP:adavisspamspam_OUTUBASICS.COM]
       Sent:   Wednesday, 8 March 2000 7:29
       To:     @spam@PICLISTKILLspamspamMITVMA.MIT.EDU
       Subject:        Re: Example

       There are only 35 instructions to learn on this PIC.  The easiest
way to learn
       how to use the PIC is to read the data sheets, and jump in.  There
are some
       books which can help you do so, and many web sites which will also
help.

       See my links to such resources at
       http://www.ubasics.com/adam/pic/

       I can help a little bit here with your questions:

       Steve Horvath wrote:
       >
       > Hello
       > I am fairly new to PIC programming, but have a fair bit of
experience form
       > school involving the Intel 8031.  I was wondering if someone could
write a
       > quick program (2 minute job) to do the fallowing on a 16f84, so
that I
       > could learn about these functions by doing them:

       First, the architecture is very different between these two mcus.
You'll find
       yourself referring to the datasheet as you program.

       > -push W onto a stack, and pop W off of the stack

       There really is no direct analogy in the PIC for your stack.  You
have no access
       to the stack in the '84.  If you want to program this way, then
you'll need to
       create a software stack (which, for most things, is inefficient.
It's just a
       different architechture, and a different way of thinking)

       > - input from port A to W when there is an interrupt

       org     4
               (Save status registers if needed here (no point in saving W
;-) )
               movf PORTA, W
               (restore status registers if needed here)
               RETFIE

       > - have a 10ms delay using the timer
       > - output to pb.0 through pb.4 after the interrupt
       > - have a 1 second timer using loops, and have the output (port B)
blink on
       > and off every second thereafter.
       >
       > oh, and could someone tell em the difference between portA and
trisA?

       Each i/o pin on the PIC can be an input, or an output.  TRISA
defines whether
       each pin in portA is input(1) or output(0).  PORTA represents the
actual status
       of PORTA.  If you are driving all pins low, but an external circuit
is driving
       them all high, then PORTA will read all high (ie, the real state,
not the state
       the PIC is trying to keep it it)

       There are other examples out there which do all of what you are
asking.  Check
       my links above, and then start asking more specific questions.

       I hope this helps!

       -Adam


       A couple of explainations of the above explainations for a beginner
-

       What is org 4 ?
       Program location 4 is the instruction that will be jumped to when an
interrupt occurs.  Normally you put a goto statement here that jumps to your
interrupt handler routine.  When you are finished handling the interrupt the
retie statement goes to the program location stored in the stack and the
program resumes from where the interrupt occurred . . .
       If you haven't turned interrupts off at the start of your handler
and stored the state of certain registers before manipulating them you will
get strange results when you turn interrupts back on and attempt to retie -
beware!

       org 0 should have a goto statement that points to the start of your
startup code.  Your program code must NOT use locations 0, 1, 2, 3 or 4 as
these are all reserved for special uses.
       It is safe to start your program from memory location 5, but I
prefer to use org 6, so my programs usually have this structure -

       org 0
               goto startup
       org 4
               goto interrupt_handler
       org 6
       startup bsf status,rp1


       The difference between portA and trisA?
       Trisa is where you set up port a.  It has (almost) the same address
as the I/O port - it is actually on the second page of memory at 0x80
higher, but you can't add 0x80 to the port a address, you have to swap to
the second page and use the same address as port a.  (Don't forget to swap
back!)

       Port a is actually 2 separate sets of circuits - 8 input circuits
and 8 output circuits.  If you set port a to output then output a 1 and then
read the port you will not see your output, you will see what was last read
in from the input circuitry.  To read the current value you have to go back
to the control page and swap the port to input and then read the input.
       Moral - try to use port pins as I or O, but don't swap them if
possible.  Set up everything in one go, then LEAVE THE I/O SETTING ALONE.


       Bye.

2000\03\07@182010 by David VanHorn

flavicon
face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is why I wrote my "getting started" package for the AVR.
It's way easier (to me anyway) to take something that's known to be
working, than to tackle, out of the gate, setting up the machine, watchdog,
timers, ints, port directions/modes, all that has to be right before you
get to blink your LED.

(Maybe a cooperative multitasker was overkill...)

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

iQA/AwUBOMW4dYFlGDz1l6VWEQJiUgCfbIT2dyli80W3dt9g2OxbDcfM6CUAoNVr
hfALJCkOPC+Miqb1Q/zQF+aM
=oopM
-----END PGP SIGNATURE-----

2000\03\07@185834 by Tony Nixon

flavicon
picon face
Steve Horvath wrote:
>
> Hello
> I am fairly new to PIC programming, but have a fair bit of experience form
> school involving the Intel 8031.  I was wondering if someone could write a
> quick program (2 minute job) to do the fallowing on a 16f84, so that I
> could learn about these functions by doing them:
> -push W onto a stack, and pop W off of the stack
> - input from port A to W when there is an interrupt
> - have a 10ms delay using the timer
> - output to pb.0 through pb.4 after the interrupt
> - have a 1 second timer using loops, and have the output (port B) blink on
> and off every second thereafter.
>
> oh, and could someone tell em the difference between portA and trisA?
>
> thanks for your help, this should pretty well be what I need to get
> everything straightened out.
>
> Steve Horvath

Here goes......

The code will be pretty rough, but you may get the idea.

If I could do all this in 2 minutes, I think I would have my own
consultancy ;-)


> -push W onto a stack, and pop W off of the stack

First off, you can't read the stack contents using a 16F84. The newer
18Cxxx series you can.
You can implement a psuedo stack in RAM however.

       clrf StackPt    ; initialise stack pointer

Subroutine to push onto the stack

Push    movwf temp      ; store W
       movf StackPt,w  ; get stack pointer
       movwf FSR       ; set ready for indirect addressing
       movf temp,w     ; get w data back
       movwf indf      ; write to current stack position
       incf StackPt    ; stack pointer + 1
       return

Subroutine to pop from stack

Pop     decf StackPt    ; stack pointer - 1
       movf StackPt,w  ; get stack pointer
       movwf FSR       ; set ready for indirect addressing
       movf indf,w     ; get stack data into w
       return


> - input from port A to W when there is an interrupt
> - have a 10ms delay using the timer
> - output to pb.0 through pb.4 after the interrupt


Assuming a 4MHz clock


       org 0h              ; start vector

       goto start

       org 4h              ; interrupt vector
;
; INTERRUPT CODE
;
       movwf W_Hold        ; store w reg - ram page 0 or 1
       swapf status,w
       bcf status,rp0      ; ram page 0
       movwf S_Hold        ; store status in RP 0

       movf porta,w        ; get porta data into W reg
       andlw b'00001111'   ; mask of upper nibble

       movwf Itemp
       movf portb,w
       andlw b'11110000'   ; mask off lower nibble
       iorwf temp,w        ; merge portb data with port a data
       movwf portb         ; send back to portb with porta (0 - 3) added

       swapf S_Hold,w      ; restore Status
       movwf status
       swapf W_Hold        ; W reg restored
       swapf W_Hold,w

       bcf intcon,t0if     ; reset tmr0 interrupt flag
       movlw 0xB2          ; reset for 10mS timeout
       movwf tmr0
       retfie              ; finished with interrupt


start   bsf status,rp0
       movlw b'11010110'   ; prescaler 1:32, used from internal clock
       movwf option_reg
       bcf status,rp0

       bsf intcon,t0ie     ; activate tmr0 interrupt
       bsf intcon,gie      ; activate global interrupts
;
; ---------
; MAIN LOOP
; ---------
;
MnLoop    nop               ; this loop does nothing
         goto MnLoop



> - have a 1 second timer using loops, and have the output (port B) blink on
> and off every second thereafter.


Assuming a 4MHz clock

       bsf status,rp0  ; ram page 1
       clrf trisb      ; all portb = outputs
       bcf status,rp0  ; back to ram page 0

ALoop   clrf portb      ; all portb = off
       call Del1Sec    ; wait 1 second
       movlw 0xff      ; all portb = on
       call Del1Sec    ; wait 1 second
       goto ALoop      ; repeat forever



1 second delay subroutine using loops

Del1Sec movlw 01h
       movwf NbHi
       movlw 06h
       movwf NbLo
       movlw 13h
       movwf NaHi
       movlw 0xB5
       movwf NaLo
DeLoop0
       decfsz NaLo
       goto DeLoop0
       decfsz NaHi
       goto DeLoop0
       decfsz NbLo
       goto DeLoop0
       decfsz NbHi
       goto DeLoop0
       return

> oh, and could someone tell em the difference between portA and trisA?

PortA(B) is the register where you write data that you want to appear on
the actual port pins.

TrisA(B) is the register that allows you to set each port pin as an
input or an output.

Any bit here set as 0, makes the corresponding port pin an output.
Any bit here set as 1, makes the corresponding port pin an input.


bsf status,rp0         ; set ram page 1 where TRISA(B) live
movlw b'00000001'      ; set all pins except bit 0 as outputs.
bcf status,rp0         ; back to ram page 1

> thanks for your help, this should pretty well be what I need to get
> everything straightened out.

Call back if you have more problems.

--
Best regards

Tony

http://www.picnpoke.com
KILLspamsalesKILLspamspampicnpoke.com

2000\03\07@190241 by Tony Nixon

flavicon
picon face
Tony Nixon wrote:

>         clrf StackPt    ; initialise stack pointer

Should have been

       movlw 0ch       ; stack pointer = first GP RAM location
       movwf StackPt

>
> Subroutine to push onto the stack
>
> Push    movwf temp      ; store W

--
Best regards

Tony

http://www.picnpoke.com
RemoveMEsalesTakeThisOuTspampicnpoke.com

2000\03\07@230548 by Jeffrey D Spears

flavicon
face
On Tue, 7 Mar 2000, Steve Horvath wrote:

> Hello
> I am fairly new to PIC programming, but have a fair bit of experience form
> school involving the Intel 8031.  I was wondering if someone could write a
> quick program (2 minute job) to do the fallowing on a 16f84, so that I
> could learn about these functions by doing them:

Hi Steve;

Two minutes eh? Well, I give it a shot.

On my mark, get set.....GO!


> -push W onto a stack, and pop W off of the stack
#include"include/stack.asm"

call push
call pop

> - input from port A to W when there is an interrupt
       org     0x04
       goto    InterruptHandler

InterruptHandler
       movf    PORTA,w
       retfie

> - have a 10ms delay using the timer

       bsf     STATUS,RP0      ;go into page one
       movlw   OPTIONInitial   ;set the prescalar and things
       movwf   OPTION_REG

       bcf     STATUS,RP0      ;back down to page zero
       movlw   TMR0TenMsDelayNumber
       movwf   TMR0
LoopDeeDoo
       movwf   TMR0
       addwf   0x00
       btfss   STATUS,Z
       goto    LoopDeeDoo

> - output to pb.0 through pb.4 after the interrupt
InteruptHandler
       andlw   0x0f    ;mask off the unwanted bits
       andwf   PORTB,w ;write to the port


> - have a 1 second timer using loops, and have the output (port B) blink on
> and off every second thereafter.
>
       #define BIT     ;any bit you want
LoopDeeDoo
       call    OneSecondTimerLoop
       btfsc   PORTB,BIT       ;Set yet?
       goto    $+3             ;Yes-> reset it
       bsf     PORTB,BIT       ;No-> set it
       goto    $+2             ;skip out
       bcf     PORTB,BIT
       goto    LoopDeeDoo

>
> oh, and could someone tell em the difference between portA and trisA?
TRISA sets the direction. Remember 1 = Input

>
> thanks for your help, this should pretty well be what I need to get
> everything straightened out.

Stop!
That took three minutes. Do I get payed overtime? No doubt all sorts
of piclisters will be correcting it anyway...

  Steve, I have been playing with PICS when time permits for the last
couple of years. Although my programming methods may be less then
professional, I have found the little buggers most intriguing.

  I use a dt001 programmer and various simmsticks with pics on them.
See http://www.dontronics.com.
and http://www.wirz.com

Although I really have nothing to compare with, it seems to be a good
low-cost system.

Freee programming and simulation software comes from Microchip
See http://www.microchip.com



>
> Steve Horvath
>


Jeffrey D. Spears
University of Michigan
College of Engineering

``Double-E, can't spell gEEk without it!''
                       -Captain Gerald M. Bloomfield II, USMC
                        (my brother)

2000\03\08@180823 by z80

flavicon
face
jona ATLAS wrote:
>
> Steve,
> If you are interested, I can send you a free book "Understanding &
> Programming the PIC16C84-a beginner4s tutorial, writed by Jim Brown). It4s
> about 25 A4 pages, now in HTML format, including commented code examples. I
> found it very usefull. It4s approx 25Kb zipped file. Just leave an Email
>
> JONA

I am not Steve, but I would love to have a look at that "beginner's tutorial"
for my own purposes, if you don't mind.

--
Mark Andrew Barclay
spamBeGonez80spamBeGonespamnewsguy.com
===================================
Work like you don't need the money,
Love like you've never been hurt,
Dance like no one is watching.

2000\03\09@111038 by Dan

flavicon
face
We would also be very grateful for a copy of this tutorial
as we are relatively new to pics.

Cheers,
Dan


On Wed, 8 Mar 2000 17:01:00 -0600 "Mark A. Barclay"
<TakeThisOuTz80EraseMEspamspam_OUTNEWSGUY.COM> wrote:

{Quote hidden}

----------------------
Dan
University of Exeter

2000\03\09@112338 by Tim Hamel

picon face
Sorry, I haven't been following this thread. I have this tutorial by Jim
Brown on my site:

http://pc-tek.hypermart.net/pic.html

Regards,

Tim Hamel


In a message dated 3/9/00 8:10:57 AM Pacific Standard Time,
D.J.BurgessEraseMEspam.....EXETER.AC.UK writes:

> We would also be very grateful for a copy of this tutorial
>  as we are relatively new to pics.
>
>  Cheers,
>  Dan
>


'Example'
2000\05\17@232013 by Alan Aldaba
flavicon
face
jona ATLAS wrote:
>
> Steve,
> If you are interested, I can send you a free book "Understanding &
> Programming the PIC16C84-a beginner4s tutorial, writed by Jim Brown). It4s
> about 25 A4 pages, now in HTML format, including commented code examples. I
> found it very usefull. It4s approx 25Kb zipped file. Just leave an Email
>
> JONA

Hi Jona,

       I would like to have a copy, kindly send me one...

Thanks,

       Allan

2000\05\17@233048 by David Huisman

flavicon
face
I am interested also thanks
EraseMEdavidspamorbitcoms.com

2000\05\17@233326 by Samuel Ace Winchenbach

flavicon
face
> Steve,
> If you are interested, I can send you a free book "Understanding &
> Programming the PIC16C84-a beginner4s tutorial, writed by Jim Brown). It4s
> about 25 A4 pages, now in HTML format, including commented code examples.
I
> found it very usefull. It4s approx 25Kb zipped file. Just leave an Email
>
> JONA


I would like a copy if it is not too much trouble?

Thanks.

RemoveMEswinchenEraseMEspamEraseMEeece.maine.edu

2000\05\18@004301 by David Huisman

flavicon
face
Could you please send me a copy

RemoveMEdavidspam_OUTspamKILLspamorbitcoms.com

Thanks

2000\05\18@023332 by lopez

flavicon
face
Mee too. Thank you. Vic Lopez
-----Original Message-----
From: Alan Aldaba <RemoveMEallenTakeThisOuTspamspamSUPER.NET.PH>
To: EraseMEPICLISTspamspamspamBeGoneMITVMA.MIT.EDU <RemoveMEPICLISTKILLspamspamMITVMA.MIT.EDU>
Date: Wednesday, May 17, 2000 9:18 PM
Subject: Re: Example


>jona ATLAS wrote:
>>
>> Steve,
>> If you are interested, I can send you a free book "Understanding &
>> Programming the PIC16C84-a beginner4s tutorial, writed by Jim Brown).
It4s
{Quote hidden}

2000\05\18@024837 by juggernut

flavicon
face
I really to have a copy too! If it is okey.. It's better if someone can
share a beginners copy of a PIC16F84 for free.

Thanks..

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...