CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pbp to ccs
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mle



Joined: 12 Sep 2003
Posts: 10

View user's profile Send private message

pbp to ccs
PostPosted: Wed Sep 17, 2003 8:53 am     Reply with quote

Hello,
I have a function written in both pbp and in ccs, and I am getting different results. The function reads 2 bytes from a ds1820 temperature sensor. I am trying to read the temperature value from the scratchpad and the pbp version gives me $0030, whereas the ccs version gives $0036. I know that the pbp version is correct. The ccs version doesn't seem to respond to different temperatures correctly and I always get $0036 for the temperature value, whereas the pbp version ranges from $0030 to $0037 as I add or remove heat.

Here is the pbp version

' Read temperature from the DS1820
read1820:
For i = 1 TO 16 ' 16 bits to a word
temp = temp >> 1 ' Shift down bits
temp.15 = 1 ' Preset read bit to 1
Low DQin ' Start the time slot
TrisB.1 = 0 ' set DQin to an output
@nop ' Delay 1us at 4MHz
TrisB.1 = 1 ' set DQin back to an input
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
IF DQIn = 0 Then
temp.15 = 0 ' Set bit to 0
EndIF
PauseUs 60 ' Wait out rest of time slot
Next i
Return
End

------------------------------------------------------------------------
And this is the ccs version

long read1wire(){

int i; //counter
int result;
long temperature; //the temperature value read in from the sensor


For (i=1; i<=16; i++){
#asm
bcf PortB,1 //pull line low to start time slot
bcf TrisB,1 //set dqin to an output
nop
bsf TrisB,1 //set dqin to an input
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
#endasm
shift_right(&temperature,2,input(DQIN));

delay_us(60);
}

return temperature;
}

Can anyone suggest why the ccs one doen't work?

Thank you,
mle
Guest








PostPosted: Wed Sep 17, 2003 9:07 am     Reply with quote

Actually it does work! I'm just doing something wrong with the temperature pointer
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

onewire library ( dallas 1wire devices / 1820 / 1822 )
PostPosted: Wed Sep 17, 2003 12:38 pm     Reply with quote

hi,

can i make a few suggestions when dealing with these onewire devices?

--make a library that you can use over and over again.
--make a library that you can optimize over time, but starts off with a lot of good debugging info including intermediate output.
--make a library that can easily be debugged.
--make a library that has no dependence on the PIC clock speed used.
--make a library that has no dependence on the PIC pin used.
--make a library that does not mix ASM and C as it violates all of the above.

in summary, make (or borrow) a library.

let me help you get you started:
http://losdos.dyndns.org:8080/public/onewire/lib-onewire.html
or
http://losdos.dyndns.org:8080/public/onewire/lib-onewire.h

regards.
Guest








Re: onewire library ( dallas 1wire devices / 1820 / 1822 )
PostPosted: Fri Dec 09, 2005 10:28 am     Reply with quote

jds-pic wrote:
hi,

can i make a few suggestions when dealing with these onewire devices?

--make a library that you can use over and over again.
--make a library that you can optimize over time, but starts off with a lot of good debugging info including intermediate output.
--make a library that can easily be debugged.
--make a library that has no dependence on the PIC clock speed used.
--make a library that has no dependence on the PIC pin used.
--make a library that does not mix ASM and C as it violates all of the above.

in summary, make (or borrow) a library.

let me help you get you started:
http://losdos.dyndns.org:8080/public/onewire/lib-onewire.html
or
http://losdos.dyndns.org:8080/public/onewire/lib-onewire.h

regards.
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 12:24 pm     Reply with quote

bcf PortB,1 //pull line low to start time slot
bcf TrisB,1 //set dqin to an output


These registers are located in different banks. Remember, you are working with inline asm where you must do this manually. Also, you must make sure the bank is in back in the state you changed it from since the compiler does not know. I might be wrong with this, I never used inline asm with the pic before. Look at your list file.

another way to do this is:

Code:
#byte port_b = 0x06
#byte TrisB = 0x86
#bit dqin_tris = TrisB.1
#bit DQIN= port_b.1

For (i=1; i<=16; i++){
DQIN = 0; //pull line low to start time slot
dqin_tris = 0; //set dqin to an output
delay_cycles(1);
dqin_tris = 1; //set dqin to an input
delay_cycles(10);
shift_right(&temperature,2,input(DQIN));

delay_us(60);
}


The compiler will know what to do then. See if this help.
_________________
-Matt
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 12:42 pm     Reply with quote

Look in the list file and make sure you will be reading each bit within the 15us slot. Also, make sure you are waiting 46us more after the 15us. Some C code can be compiled into longer or shorter asm than you think.
_________________
-Matt
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 1:06 pm     Reply with quote

when are we members going to stand up and put a stop to "guest" posting? this thread is over 2 years old but gets resurrected by a "guest", wasting a lot of folks time replying to a dead topic.

jds-pic
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 1:09 pm     Reply with quote

To DragonPic:
You're responding to the notorious "guest", who every day dredges up
some old thread and then quotes part of it, without adding anything of
value.

To jds:
Someone will have to ask Darren to handle it.
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 1:40 pm     Reply with quote

lol..... What a jerk. At least I learn more than something.
_________________
-Matt
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 1:43 pm     Reply with quote

I only replied to it because I though it had to do with the "
Read temperature maximum minimum ds1624" post.
_________________
-Matt
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 09, 2005 5:21 pm     Reply with quote

PCM programmer wrote:
To DragonPic:
You're responding to the notorious "guest", who every day dredges up
some old thread and then quotes part of it, without adding anything of
value.

To jds:
Someone will have to ask Darren to handle it.


Interesting, I never noticed this before.

I think forcing people to register or locking threads after a long period of time would be more annoying then whatever this person's intentions are. What do you guys think? Also, what do you think this guys intentions are, I can't figure it out.
mkent



Joined: 09 Sep 2003
Posts: 37
Location: TN, USA

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 6:31 pm     Reply with quote

I would be in favor of letting people read all, but have to be registered and signed on in order to post.
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Dec 09, 2005 8:15 pm     Reply with quote

I very definitely agree.

Many of the forums allow reading for all but require registration to post. That might help things in this forum.

I am very much in favor of eliminating/blocking "guest" posting entirely.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 10, 2005 2:14 pm     Reply with quote

Quote:
Also, what do you think this guys intentions are, I can't figure it out.

It just occurred to me... what if "guest" is not really a person, but is a 'bot
that is attempting to place advertisements on the board ? (But for some
reason it fails, and just ends up quoting an old post). You could check
your IP logs, and if it's always the same IP, you could ban that IP from
posting. That might stop the 'bot.

Here are a few recent threads where "guest" just quoted a post:
http://www.ccsinfo.com/forum/viewtopic.php?t=18293
http://www.ccsinfo.com/forum/viewtopic.php?t=21455
http://www.ccsinfo.com/forum/viewtopic.php?t=22929
http://www.ccsinfo.com/forum/viewtopic.php?t=1976
Ttelmah
Guest







PostPosted: Sat Dec 10, 2005 4:34 pm     Reply with quote

The text input 'confirmation code' system, should prevent any 'bot' from doing this. I'm afraid this is either a glitch, or a real person.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group