Searching \ for '[PIC:] Cooked a 16F627' 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=16F
Search entire site for: 'Cooked a 16F627'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] Cooked a 16F627'
2004\03\06@173629 by Anthony Toft

flavicon
face
Well I thought I had finally finished my trigger project, but after
unsoldering the test points and soldering back in the resistor, it
ceased working.

After some investigation I had soldered everything back together with it
turned on, I had also gotten a bridged joint. Needless to say I wanted
to test the PIC. I wrote the attached ASM to basically oscillate the
outputs and give me something to look at on the scope. I am expecting to
see a square wave...

The test circuit is literally VDD to +5v and VSS to 0v, nothing else. I
was going to use the internal osc for this.

Could someone take a look at it and tell me if my code might work at
what I am trying, thanks...


       title "PIC16F627 e-trigger"
       list p=16f627,f=inhx32
#include <p16f627.inc>

   __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _BODEN_OFF & _CP_OFF &
_DATA_CP_OFF & _LVP_OFF & _MCLRE_OFF

   CBLOCK 0x20
rolls
state
   ENDC

   org 00h
   goto Start
   org 04h

   BCF INTCON,T0IF ;clear the flag

   DECFSZ rolls,1
   GOTO END_INT

   BTFSC state,0
   GOTO TURN_OFF
TURN_ON
   BSF state,0
   MOVLW 0xFF
   MOVWF PORTA
   MOVWF PORTB

   GOTO END_INT
TURN_OFF
   BCF state,0
   MOVLW 0
   MOVWF PORTA
   MOVWF PORTB

END_INT
   RETFIE

Start

   ; turn off the comparators
   MOVLW 0x07
   MOVWF CMCON

       ; switch to bank 1 to affect the TRIS registers
   BCF STATUS,RP1
   BSF STATUS,RP0 ;select bank1


       ; set A and B as outputs
   MOVLW 0x00
   MOVWF TRISA
   MOVWF TRISB
   ; Make the timer a timer not a counter...
   BCF OPTION_REG,T0CS
   ; Back to bank 0
   BCF STATUS,RP0

   MOVLW 0
   MOVWF rolls
   MOVWF state
   ; enable tmr0 interrupts

   BSF INTCON,T0IE
   ; turn them on
   BSF INTCON,GIE

   ; enter an endless loop, here we go to interrupt
   ; based operation.
LOOP

   GOTO LOOP

   END

--
Anthony Toft <spam_OUTtoftatTakeThisOuTspamcowshed.8m.com>

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

2004\03\06@185706 by Jinx

face picon face
> After some investigation I had soldered everything back together with
> it turned on

Ooops

> I had also gotten a bridged joint

Ooops

Have you tried another chip ? A reasonable investigative step

> Could someone take a look at it and tell me if my code might work
> at what I am trying, thanks...

At first glance it looks OK and seems to compile alright. Assuming
no other electrical horrors have been or are currently inflicted on the
poor thing it should work

There are a few things you could do to make the code a little more
readable and quicker/easier to type

For example, use XOR to toggle bits (be aware of read-write-modify
when changing port bits directly. It sometimes pays to manipulate bits
in a shadow register, which is then written to the port). 0XFF will simply
invert the state of all the PORTA bits

MOVF  PORTA,W
;perhaps copy W to a shadow register here
XORLW 0XFF       ;or b'11111111'
MOVWF PORTA   ;or write the shadow register via W back to the port

or

MOVLW 0XFF
XORWF PORTA

XOR can be used to turn a bit off (if it was on, but there's more to it
than that which could impact on other port bits), IOR to turn it on. Try
a few binary examples in a Watch window. For individual bits, define
them so you can address them by name

eg #DEFINE testpoint1   PORTA,0

CLRF instead of MOVLW 0X00, MOVWF

RETFIE instead of GOTO END_INT (saves reader looking for END_INT)

BANKSEL TRISA to go to Bank1
BANKSEL PORTA to go to Bank0

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

2004\03\06@211012 by Anthony Toft

flavicon
face
> Ooops

Exactly my words

> Ooops

The second time I was a bit more colourfull

> Have you tried another chip ? A reasonable investigative step

Unfortunately I don't have them floating around spare, this is my first
PIC project, next time I will pad my order with some other parts for
this reason...

> At first glance it looks OK and seems to compile alright. Assuming
> no other electrical horrors have been or are currently inflicted on the
> poor thing it should work

It might be the batteries in my programmer, I am having all sorts of
problems getting it programmed.

> There are a few things you could do to make the code a little more
> readable and quicker/easier to type

Usually I am better with my code, but this was a throw it together, see
it work thing.

> XORLW 0XFF       ;or b'11111111'

I keep forgetting the side effect of the XOR operator, I rarely use it
at all. In this case I will just do the literals, all I want is to see
that square wave.

> eg #DEFINE testpoint1   PORTA,0

I am unfortunately one of those that believes that some macros are good,
but not the more macros are better.

> CLRF instead of MOVLW 0X00, MOVWF

Yes, my PIC asm is showing :)

> RETFIE instead of GOTO END_INT (saves reader looking for END_INT)

Now my C experience is showing, there should be at most 2 returns in a
function (once the parameter checking is done), it's easier to keep all
the allocations straight.

> BANKSEL TRISA to go to Bank1
> BANKSEL PORTA to go to Bank0

I wish these would turn off the Register in operand not in bank 0
message, I like warnings to warn, but if I get it right they shouldn't
be there.

Thanks!

--
Anthony Toft <.....toftatKILLspamspam.....cowshed.8m.com>

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

2004\03\06@215442 by Jinx

face picon face
> > eg #DEFINE testpoint1   PORTA,0
>
> I am unfortunately one of those that believes that some macros
> are good, but not the more macros are better

A define isn't a macro. When you have a project with heavy port
usage (or even using just 1 i/o), defining pins with names saves
so much brain work. Even while still working on a program, you
don't need to fatigue yourself remembering what BCF PORTA,0
does. BCF testpoint1 for me, thank you

> I wish these would turn off the Register in operand not in bank 0
> message, I like warnings to warn, but if I get it right they shouldn't
> be there.

You can suppress warnings and errors. I always include this line
in .asm files

errorlevel -305, -302, -306

Look under Errorlevel and Messages - Assembler in

Help/Microchip Language Tools Help/MPASM Assembler Help

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

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