Searching \ for 'New To PIC What am I doing wrong?' 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/microchip/devices.htm?key=pic
Search entire site for: 'New To PIC What am I doing wrong?'.

Truncated match.
PICList Thread
'New To PIC What am I doing wrong?'
1997\05\29@095553 by Glen Benson

flavicon
face
Hi,

 I am new to PIC, cant get a handle on asm fast enough. So I bought a
basic compiler. I can write all sorts of neat things I dont need to do, But
I cant get the following code to work in less than about 2 seconds. I need
to take an ADC reading stuff it in to a varible and send it to the PC via
lpt port. For my test I use qbasic and turn on Pin 7 of the PIC with the
(out lpt,1 statement) then
I read the level of pin 6 on the pick to see if hi or low then I shift the
value in B0 , and do it 7 more times. I have to put 2 second delays in the
qbasic code
to make it work. Thats .5 hz (its got to go faster than that). Please if
you see my blunder, can you show me? :)


' a qbasic program turns on PIN 7, then the qbasic prog. reads
' the value on (lpt pin10) connected to (PIC on PIN 6) and repeats
' 8 times toget the whole byte. The qbasic prog has to have
' 2 second delays to get the right data. How could this
' be written better? It cant get worse.



Symbol  DDIR = Dir6           ' Shift data pin direction is Dir1
Symbol  DPIN = Pin6           ' Shift data pin is 6
Symbol  CPIN = 1              ' Shift clock pin is 1
       input 7               ' Make pin 7 an input

START:  B0=65                 ' value to shift out

loop: pause 1                 'didnt seem to work without this
     if pin7=1 then getbit   ' pin 1 from lpt just went high
     goto loop

getbit: DDIR = 1             ' set the direction of the pin
       DPIN = bit0          ' get the bit send it out to pin 10 on lpt
       B0=B0/2              ' shift the value in B0 over
       goto loop


Thanks
Glen Benson

1997\05\29@115917 by Eric Martens

flavicon
face
This may be the cause of the problem ( i had a same kind of problem on a 68000)

A program written in assembler will work quicker then the same program written
in basic
or another language. The overhead of the program is less or none if you write in
assembler. When you write in a langauge other then assembler the program listing
(compiled program) tends to be longer, thus resulting in a longer runtime on the
proc.

Greetings Eric Martens

***************************
*  Eric Martens           *
*  spam_OUTemarTakeThisOuTspamknoware.nl  *
**************************


----------
| From: Glen Benson <.....bensonKILLspamspam@spam@BENSONASSOC.COM>
| To: PICLISTspamKILLspamMITVMA.MIT.EDU
| Subject: New To PIC What am I doing wrong?
| Date: donderdag 29 mei 1997 14:08
|
| Hi,
|
|   I am new to PIC, cant get a handle on asm fast enough. So I bought a
| basic compiler. I can write all sorts of neat things I dont need to do, But
| I cant get the following code to work in less than about 2 seconds. I need
| to take an ADC reading stuff it in to a varible and send it to the PC via
| lpt port. For my test I use qbasic and turn on Pin 7 of the PIC with the
| (out lpt,1 statement) then
| I read the level of pin 6 on the pick to see if hi or low then I shift the
| value in B0 , and do it 7 more times. I have to put 2 second delays in the
| qbasic code
| to make it work. Thats .5 hz (its got to go faster than that). Please if
| you see my blunder, can you show me? :)
|
|
| ' a qbasic program turns on PIN 7, then the qbasic prog. reads
| ' the value on (lpt pin10) connected to (PIC on PIN 6) and repeats
| ' 8 times toget the whole byte. The qbasic prog has to have
| ' 2 second delays to get the right data. How could this
| ' be written better? It cant get worse.
|
|
|
| Symbol  DDIR = Dir6           ' Shift data pin direction is Dir1
| Symbol  DPIN = Pin6           ' Shift data pin is 6
| Symbol  CPIN = 1              ' Shift clock pin is 1
|         input 7               ' Make pin 7 an input
|
| START:  B0=65                 ' value to shift out
|
| loop: pause 1                 'didnt seem to work without this
|       if pin7=1 then getbit   ' pin 1 from lpt just went high
|       goto loop
|
| getbit: DDIR = 1             ' set the direction of the pin
|         DPIN = bit0          ' get the bit send it out to pin 10 on lpt
|         B0=B0/2              ' shift the value in B0 over
|         goto loop
|
|
| Thanks
| Glen Benson

1997\05\30@091811 by Paul Kolesnikoff

flavicon
face
Date:    Thu, 29 May 1997 07:08:52 EST
From:    Glen Benson <.....bensonKILLspamspam.....BENSONASSOC.COM>
Subject: New To PIC What am I doing wrong?

Hi,

 I am new to PIC, cant get a handle on asm fast enough. So I bought a
basic compiler. I can write all sorts of neat things I dont need to do,
But
I cant get the following code to work in less than about 2 seconds. I
need
to take an ADC reading stuff it in to a varible and send it to the PC
via
lpt port. For my test I use qbasic and turn on Pin 7 of the PIC with the
(out lpt,1 statement) then
I read the level of pin 6 on the pick to see if hi or low then I shift
the
value in B0 , and do it 7 more times. I have to put 2 second delays in
the
qbasic code
to make it work. Thats .5 hz (its got to go faster than that). Please if
you see my blunder, can you show me? :)


' a qbasic program turns on PIN 7, then the qbasic prog. reads
' the value on (lpt pin10) connected to (PIC on PIN 6) and repeats
' 8 times toget the whole byte. The qbasic prog has to have
' 2 second delays to get the right data. How could this
' be written better? It cant get worse.



Symbol  DDIR = Dir6           ' Shift data pin direction is Dir1
Symbol  DPIN = Pin6           ' Shift data pin is 6
Symbol  CPIN = 1              ' Shift clock pin is 1
       input 7               ' Make pin 7 an input

START:  B0=65                 ' value to shift out

loop: pause 1                 'didnt seem to work without this
     if pin7=1 then getbit   ' pin 1 from lpt just went high
     goto loop

getbit: DDIR = 1             ' set the direction of the pin
       DPIN = bit0          ' get the bit send it out to pin 10 on lpt
       B0=B0/2              ' shift the value in B0 over
       goto loop


Thanks
Glen Benson

------------------------------
Glen,

Try changing your code to this.

loop:
     if pin7=1 then getbit      ' pin 1 from lpt just went high
     goto loop

getbit: DDIR = 1                  ' set the direction of the pin
       DPIN = bit0                ' get the bit send it out to pin 10
on lpt
       B0=B0/2                    ' shift the value in B0 over
       if pin7=0 then loop       ' wait for Pin 7 to go low before
looking for new bit

Essentially you are implementing a synchronous data transfer, with the
PC providing the clock. It looks like your original code would sense the
first clock pulse and then shift out a bunch of bits before the second
clock pulse. The extra IF should keep you in sync. If you want to speed
it up a bit more, send byte wide or nibble wide data for every PIN 7
clock pulse. You have up to 9 input pins on a standard parallel port. So
the limit is the number of pins available on your PIC.

Let me know how it goes,
Paul Kolesnikoff
EraseMEpkolesnispam_OUTspamTakeThisOuTball.com

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