Searching \ for 'Application Code' 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=application+code
Search entire site for: 'Application Code'.

Truncated match.
PICList Thread
'Application Code'
1998\11\10@093743 by darwin

flavicon
face
Hi, to all PICer, I have a question that I want to ask .
Once you've learned the code for the PIC, how do you develope
your own program ?  what I mean to say is, for example.  how do I make
a LED flash three times wait for a key to be press and then sound a
buzzer
if no key have been pressed.

Darwin Reynoso

1998\11\10@102141 by darwin

flavicon
face
Thanks for the advice Mr. Baptista, but I still don't get it.
You learn the opcode, and then  you think of something, and then you
program it.
Can you or anyone send me an example of a program that will do the
following:

Power on, flash a LED three times wait for a key to be pressed
if no key have been pressed sound a buzer.

Darwin Reynoso

1998\11\10@120223 by andre

flavicon
face
Darwin Reynoso wrote:

> Hi, to all PICer, I have a question that I want to ask .
> Once you've learned the code for the PIC, how do you develope
> your own program ?  what I mean to say is, for example.  how do I make
> a LED flash three times

first you load  value 3 save it in ram then call your blink routinethe end
of blink routine it will decrement your saved value then it will
skip if the value = 0 if no will go back all together it will blink  3
times  .
it this what you need .


               movlw    .3
               movwf    count

loop         bsf    portb,0                ; portb,0 is your led
               call    delay
               bcf    portb,0
               call    delay

               decfsz    count,f
               goto        loop

               btfsc        portb,1        ; portb,1 is your switch
               goto        loop
               call        sound
               goto        loop


you need to add sound and delay routine

> wait for a key to be press and then sound a
> buzzer
>

you use bit test "BTFSS or BTFSC"

> if no key have been pressed.
>

same as above

> Darwin Reynoso

Andre Abelian

1998\11\11@161848 by Caisson

flavicon
face
> Van: Darwin Reynoso <spam_OUTdarwinTakeThisOuTspamfuse.net>
> Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Onderwerp: Application Code
> Datum: woensdag 11 november 1998 15:36
>
> Hi, to all PICer, I have a question that I want to ask .

Hello Darwin,

> Once you've learned the code for the PIC, how do you develope
> your own program ?  what I mean to say is, for example.  how do I make
> a LED flash three times wait for a key to be press and then sound a
> buzzer if no key have been pressed.

Hey ! No fair !  You ask me to tell you how to do it and than giving the
answer yourself ...  As you said, you break-up the program in (simpler)
parts.

[1] Flash a LED three times.  Create a routine that will switch a LED on,
waits, switches Off and waits some more.  That's one flash of the LED.  Now
you've got two options : [a] call your flash-the-LED routine three times or
[b] create a loop that will be executed three times.

[2] Check if a key is pressed (don't _wait_ for the key).  Eventually
De-bouncing the input.  It can be done this way :  [a] Check if a key is
down.  If not, try again until a Loop-counter reaches Zero.  If it does,
exit the De-bounce routine with a "no key pressed" value. Next : [b] Check
if the key is _still_down.  If it is _not_ go back to [a].  If it is, try
again until a Loop-counter reaches Zero.  If does, it exit the De-bounce
routine with a "key _is_ pressed" value.

[3] Check the Key_pressed value.  If it's not pressed call the
Beep-routine.

[4] Beep the Loud-speaker.  This is a routine that is similar to the
Flash-a-LED routine, but the Wait-times are somewhat shorter :-)


That's all there is to it ...  So, Divide your problem into their "atoms"
(smallest, undividable parts), Write an "atom" & check if it works. Than
move on to the next "atom"  If two "atoms" do something together write the
"atom" that connects those two.  You can look at it like a Piramide :
First place the lowest stones, Put a row of stones ontop of that one, and
so on.  The last stone is the top of the piramide, and is the main-program
loop.  The technique is called "bottom Up programming".

Greetz,
 Rudy Wieser

1998\11\12@163904 by John Sanderson

flavicon
face
Hello PIC.ers,
..
>[4] Beep the Loud-speaker.  This is a routine that is similar to the
>Flash-a-LED routine, but the Wait-times are somewhat shorter :-)
>
>
>That's all there is to it ...  So, Divide your problem into their "atoms"
>(smallest, undividable parts), Write an "atom" & check if it works. Than
>move on to the next "atom"  If two "atoms" do something together write the
>"atom" that connects those two.  You can look at it like a Piramide :
>First place the lowest stones, Put a row of stones ontop of that one, and
>so on.  The last stone is the top of the piramide, and is the main-program
>loop.  The technique is called "bottom Up programming".
>
>Greetz,
>  Rudy Wieser
..
Aye, indeed,    indeed aye.
All my paying product seems to get made this way.
..
That's despite the rules which put it that we should practice
`top-down' programming.        i.e.
Devise the general plan of attack,
then break it down into compartment-isable hunks, each capable of being
dealt with on it's own. Split that down further into individual repetitive
i/o calls, etc. right down to bare metal.
..
Maybe I'm a Neanderthal in this, but I find it well nigh impossible
to walk confidently up the `top-down'  s/w design staircase until
I'm (first) totally sure of the planks I'm standing on.
Those real low-level routines gotta be nailed down first.
..
comments?      ... come on now, I know you're out there !
..
Best regards,   John

..
email from John Sanderson at
JS Controls, PO Box 1887, Boksburg 1460, Rep. South Africa
Manufacturer & purveyor of laboratory force testing apparatus
and related products and services.
Tel/fax: Johannesburg 893 4154    Cellphone 082 453 4815

1998\11\13@024404 by Mark Willis

flavicon
face
John Sanderson wrote:
{Quote hidden}

 I start with a little top-down (just enough to nail the hardware down
roughly, and figure out what foundation is needed, then go to bottom-up
as that's the best to work next.  You need to know something about what
functionality is needed in the foundation, though, or you cannot make
'em (i.e. for a real time OS you know you need to sometimes fragment up
the serial port test code, digital filtering, sorting algorithms, and
flash data storage and retreival code into small chunks, designing with
this in mind from the beginning will reduce a LOT of code reworking
hassles and headaches later.  If you're running a straight-through game
or state machine type controller, you can code it differently!)  But
those low-level routines do need to work right or your whole house of
cards will fall <G>

 I usually find that I work best at the bare metal level, revise the
code & hardware with the top level in mind but focussing on the low
level code.  (I try to reality check with the top level design criteria
regularly, at least <G>)

 Mark, mwillisspamKILLspamnwlink.com

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