Searching \ for '[PIC]: 12C509A Questions' 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: '12C509A Questions'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 12C509A Questions'
2001\12\12@130151 by James Paul

picon face
All,

I have programmed a 12C509A to toggle 2 outputs out of pahse with one
another.  It seems to simulate fine.  And it runs in the processor fine
for a while.  But when I connect a 1K resistor to each output through
a .1uF cap, both outputs wind up in phase.

How can this happen?  Anybody have any ideas?

I have included the source file below for your perusal.

Any ideas would be greatly appreciated.




.... Source file....


;**********************************************************************
;                                                                     *
;   Filename:............. PSPulse.asm                                *
;    Date: ................ 12/10/01                                  *
;    File Version: ........ 1.30                                      *
;                                                                     *
;    Author: .............. Jim Paul                                  *
;    Company: ............. Applied MEMS Inc.                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: 12C509A.INC                                      *
;                                                                     *
;                                                                     *
;**********************************************************************


    list      p=12c509a           ; list directive to define processor
    #include <p12c509a.inc>       ; processor specific variable definitions

       __CONFIG   _CP_OFF & _XT_OSC & _WDT_OFF

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc
file.
; See respective data sheet for additional information on configuration
word.




;**********************************************************************
       ORG     0x001   ; processor reset vector

LOOP1

       movlw   0x00            ; Load 'w' with '00'
       movwf   0x06            ; Set all pins to logic low
       tris    GPIO            ; Send it to the DDR to make all Outputs.


       bsf     GPIO,0          ; Turn off Output 0 in known state.
       bcf     GPIO,1          ; Turn off Output 1 in known state.

       movlw   0x03            ; load w with '3'
       xorwf   0x06,1          ; Toggle the outputs
       goto    $-1             ; go back and toggle again


       END                     ; directive 'end of program'

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\12\12@130201 by James Paul

picon face
All,

I have programmed a 12C509A to toggle 2 outputs out of pahse with one
another.  It seems to simulate fine.  And it runs in the processor fine
for a while.  But when I connect a 1K resistor to each output through
a .1uF cap, both outputs wind up in phase.

How can this happen?  Anybody have any ideas?

I have included the source file below for your perusal.

Any ideas would be greatly appreciated.


                    Thanks all,

                     Regards,

                       Jim




.... Source file....


;**********************************************************************
;                                                                     *
;   Filename:............. PSPulse.asm                                *
;    Date: ................ 12/10/01                                  *
;    File Version: ........ 1.30                                      *
;                                                                     *
;    Author: .............. Jim Paul                                  *
;    Company: ............. Applied MEMS Inc.                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: 12C509A.INC                                      *
;                                                                     *
;                                                                     *
;**********************************************************************


    list      p=12c509a           ; list directive to define processor
    #include <p12c509a.inc>       ; processor specific variable definitions

       __CONFIG   _CP_OFF & _XT_OSC & _WDT_OFF

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc
file.
; See respective data sheet for additional information on configuration
word.




;**********************************************************************
       ORG     0x001   ; processor reset vector

LOOP1

       movlw   0x00            ; Load 'w' with '00'
       movwf   0x06            ; Set all pins to logic low
       tris    GPIO            ; Send it to the DDR to make all Outputs.


       bsf     GPIO,0          ; Turn off Output 0 in known state.
       bcf     GPIO,1          ; Turn off Output 1 in known state.

       movlw   0x03            ; load w with '3'
       xorwf   0x06,1          ; Toggle the outputs
       goto    $-1             ; go back and toggle again


       END                     ; directive 'end of program'

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\12\12@133431 by mike

flavicon
face
The external load is slowing down the slew-rate of the port pin. Both the bsf/bcf operations and the XORWF are reading the whole port
byte, modifying the required bits, and then writing it back. If the
pin has not stabilised from the previous write, it may read back the
wrong value. I suspect it's the bsf/bcf in your case, as 1K/100n is not a heavy
load. Look at it in slow-motion. Assume the port is initially 00

bsf GPIO,0
voltage on pin starts rising....
bcf GPIO,1
reads port, but due to loading, bit 0 has not yet got all the way up to the input 'high' threshold, so it reads back as 0,
not the 1 you want it to be, so this operation reads bit 0 as 0, clears bit 1, and writes the
result to GPIO, i.e. 00
The fix is to either avoid read-modify-write instructions, or add some
delay between them. e.g. replacing your bsf/bcf with  movlw 1
movwf gpio

would work, but the XORWF operation may still suffer the same problem
- either add some delay (for 1K/100n, only a few cycles should be
necessary), or flip the bits in W or another variable and write the
new value



On Wed, 12 Dec 2001 12:00:05 +0600, you wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\12\12@134625 by Andrew Warren

flavicon
face
James Paul <.....PICLISTKILLspamspam.....mitvma.mit.edu> wrote:

>  I have programmed a 12C509A to toggle 2 outputs out of pahse with one
> another.  It seems to simulate fine.  And it runs in the processor fine
> for a while.  But when I connect a 1K resistor to each output through a
> .1uF cap, both outputs wind up in phase.

James:

When your XORWF instruction reads PORTB, it sees the voltage that's
on the pin.  That voltage is not necessarily the same as the value
that you previously wrote to the port, especially if you've put some
capacitance on the pin and thereby slowed the pin's rise-time.

You can fix your code two ways:

1.  Put a delay between successive XRWFs.

2.  Rewrite it so you no longer do read-modify-writes on the port
   itself:

   OLD:
   ----

     bsf     GPIO,0    ;Turn off [sic] Output 0 in known state.
     bcf     GPIO,1    ;Turn off Output 1 in known state.

     movlw   0x03      ;load w with '3'
     xorwf   0x06,1    ;Toggle the outputs
     goto    $-1       ;go back and toggle again

   NEW, with a shadow register:
   ----------------------------

     SHADOW  EQU [any file register]

         MOVLW   0x01
         MOVWF   GPIO
         MOVWF   SHADOW

     LOOP:

         MOVLW   0x03
         XORWF   SHADOW
         MOVF    SHADOW,W
         MOVWF   GPIO
         GOTO    LOOP

   NEW, without:
   -------------

         MOVLW   0x01
         MOVWF   GPIO

     LOOP:

         XORLW   0x03
         MOVWF   GPIO
         GOTO    LOOP

If you implement either of the above, you'll see that your outputs
don't go rail-to-rail; that's because you're toggling faster than the
capacitance on the outputs will allow, and it's why you were having
those problems originally.

-Andrew

=== Andrew Warren -- EraseMEaiwspam_OUTspamTakeThisOuTcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2001\12\12@135414 by Bob Barr

flavicon
face
On Wed, 12 Dec 2001 12:00:05 +0600, James Paul wrote:

> All,
>
> I have programmed a 12C509A to toggle 2 outputs out of pahse with one
> another.  It seems to simulate fine.  And it runs in the processor fine
> for a while.  But when I connect a 1K resistor to each output through
> a .1uF cap, both outputs wind up in phase.
>
> How can this happen?  Anybody have any ideas?
>
> I have included the source file below for your perusal.
>
> Any ideas would be greatly appreciated.
>

Welcome to the wacky world of read-modify-write operations.

When you perform the XOR on the port pins, three things have to
happen:

1. the port *pins* are read

2. the XOR operation is applied to the data just read

3. the port *register* is written with the new data and it then
appears on the output pins

All of this happens in one instruction cycle with the read occuring in
the first quarter of the cycle and the write occuring in the last.


If you follow this XOR operation (shortly thereafter) with another
one, the new data will not have had time to stabilize on the output
pins before you read them for that second operation.
Operating speed and pin capacitance can greatly affect the reliability
of r-m-w operations on I/O ports. (I generally avoid them if at all
possible and it usually is.) You could try performing the XOR on a RAM
location and then writing the RAM's contents to the port.

Regards, Bob

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\12\12@152440 by Andre Abelian

picon face
Jim

Your code looks ok are you using scope or
leds to check it? Because using leds
There is no way you can see it. make sure your
Programmer firmware version is up to date.

Andre Abelian



All,

I have programmed a 12C509A to toggle 2 outputs out of pahse with one
another.  It seems to simulate fine.  And it runs in the processor fine
for a while.  But when I connect a 1K resistor to each output through
a .1uF cap, both outputs wind up in phase.

How can this happen?  Anybody have any ideas?

I have included the source file below for your perusal.

Any ideas would be greatly appreciated.




.... Source file....


;**********************************************************************
;                                                                     *
;   Filename:............. PSPulse.asm                                *
;    Date: ................ 12/10/01                                  *
;    File Version: ........ 1.30                                      *
;                                                                     *
;    Author: .............. Jim Paul                                  *
;    Company: ............. Applied MEMS Inc.                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: 12C509A.INC                                      *
;                                                                     *
;                                                                     *
;**********************************************************************


    list      p=12c509a           ; list directive to define processor
    #include <p12c509a.inc>       ; processor specific variable
definitions

       __CONFIG   _CP_OFF & _XT_OSC & _WDT_OFF

; '__CONFIG' directive is used to embed configuration word within .asm
file.
; The lables following the directive are located in the respective .inc
file.
; See respective data sheet for additional information on configuration
word.




;**********************************************************************
       ORG     0x001   ; processor reset vector

LOOP1

       movlw   0x00            ; Load 'w' with '00'
       movwf   0x06            ; Set all pins to logic low
       tris    GPIO            ; Send it to the DDR to make all
Outputs.


       bsf     GPIO,0          ; Turn off Output 0 in known state.
       bcf     GPIO,1          ; Turn off Output 1 in known state.

       movlw   0x03            ; load w with '3'
       xorwf   0x06,1          ; Toggle the outputs
       goto    $-1             ; go back and toggle again


       END                     ; directive 'end of program'

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\12\16@172842 by Alexandre Domingos F. Souza

flavicon
face
>When your XORWF instruction reads PORTB, it sees the voltage that's
>on the pin.  That voltage is not necessarily the same as the value
>that you previously wrote to the port, especially if you've put some
>capacitance on the pin and thereby slowed the pin's rise-time.

       Wow, that was great! Thanks for the info, Andrew!


---8<---Corte aqui---8<----

Alexandre Souza
spamBeGonetaitospamBeGonespamterra.com.br
http://planeta.terra.com.br/lazer/pinball/

---8<---Corte aqui---8<----

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


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