Go to Post Definitely read through ALL the documentation, and if you still have questions, ask. - Joe Ross [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 05-10-2005, 17:22
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: 16 bit math on PIC


I think for the 12F, the code could be done as follows. There isn't a ADDWFC (add w/carry) as there is on the 18F so I suppose you just test the Carry bit in the status reg directly?). Anyway, I might have flipped the value of the carry bit but I believe it is asserted to 1 upon carry out and asserted to 0 for a borrow - but I might have them mixed up so make sure you test this before using it. Just one way, I'm sure there are lots of others.

Code:
Where a is at address 0x20/0x21
      b               0x22/0x23
      c               0x24/0x25

:                   c = a+b;
     MOVF   0x20, W           ; a.lo              -> W
     ADDWF  0x22, W           ; W + b.lo          -> W, set carry bit status
     MOVWF  0x24              ;                      W -> c.lo
     MOVF   0x21, W           ; a.hi              -> W
     BTFSC  STATUS,C          ; test carry bit in STATUS[0x03].<0>
     ADDLW  1,    W           ; W + Carry in bit  -> W
     ADDWF  0x23, W           ; W + b.hi          -> W
     MOVWF  0x25              ;                      W -> c.hi

:                  c = a-b;
     MOVF   0x20, W           ; a.lo              -> W
     SUBWF  0x22, W           ; W - b.lo          -> W, set borrow bit status
     MOVWF  0x24              ;                      W -> c.lo
     MOVF   0x21, W           ; a.hi              -> W
     BTFSS  STATUS,C          ; test carry bit in STATUS[0x03].<0>
     SUBLW  1,    W           ; W - Borrow        -> W
     SUBWF  0x23, W           ; b.hi - W          -> W
     MOVWF  0x25              ;                      W -> c.hi
  #17   Spotlight this post!  
Unread 05-10-2005, 18:43
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: 16 bit math on PIC

Quote:
Originally Posted by sciguy125
... And if you don't need a reset pin, you configure that to be an I/O also. In the process of doing that, it occured to me that the chip would start running the program and disable the reset as soon as it's plugged into my JDM programmer. ...
you are right, if you use the reset and both programmer pins on the chip as outputs, then the device will take off running when its programmed, and the programmer wont be able to gain control of it again.

Making the two programmer pins inputs solves the problem. I did the same thing - check the programming data sheet - I think its only a problem if the SW drives one or both programming pins high (or low? I forget).
  #18   Spotlight this post!  
Unread 07-10-2005, 02:57
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: 16 bit math on PIC

Quote:
Originally Posted by sciguy125
Now, if you'll excuse me, I think I have some 2N7000's in the garage somewhere to fix my programmmer.
As a note to anyone here who might try that modification, I ran into some trouble with it. After spending hours checking and rechecking the hardware, it turned out to be a software issue. (It's always the other one...) I had to increase the "clock delay", as PikDev calls it. In IC-Prog it's called "I/O delay". I haven't experimented yet to find the minimum setting, but my arbitrary selection of 25 in IC-Prog worked.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PIC 18F2431 Sparks333 Programming 9 24-08-2005 01:24
Can the pic controller send the data to pc? sunnyrx7turbo Control System 2 05-08-2005 13:14
Linux and new microcontollers. djcapelis Programming 48 29-01-2005 00:26


All times are GMT -5. The time now is 10:28.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi