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 CCS Technical Support

Timer0 Problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chriss2000
Guest







Timer0 Problems
PostPosted: Thu Jan 23, 2003 1:35 pm     Reply with quote

<font face="Courier New" size=-1>This is a code for manchester decoding !
can anyone tell me why the syntax
if(count>abtast)
..
doesn't work ??
There i want to ask if the counter value is greater than my scanvalue !?!
if(count>10) for instance works, why can't i put there a integer ???


#include <16f876.h>
#Device ICD=TRUE
#use delay(clock=4000000)

int newbit=0,flag=0,i=0,a=0;
long count=0,code=0,zero=0,abtast=10;

#int_ext
isr()
{
flag=1;
}
void main()
{
set_tris_A(0xFF);
set_tris_B(0xFF);
set_tris_C(0x00);
setup_timer_0(RTCC_DIV_128|RTCC_INTERNAL);
//Timer 0 Setup --> Interner RTCC Teilung durch 128--> zählt mit 7.8125kHz//Teilung: beim Zählstand 1 sind 128us vergangen;in 1ms zählt er bis 7.8125
enable_interrupts(int_ext);
ext_int_edge(H_TO_L);
enable_interrupts(global);
while(True)
{
while(flag == 1)
{
disable_interrupts(global);
if(i<14) //14 mal abtasten
{
set_timer0(10);
count=get_timer0();
if(count>=abtast)
{

newbit=input(Pin_A0); code=zero|newbit; code=code<<1; abtast=abtast+14; //abtast um 14 erhöhen [1,792ms]
output_c(0xFF);
i++;
}
}
flag=0; abtast=10;
//Timerwert 10 entspricht 1,3ms, wodurch das Abtasten des neuen Signals im 3/4ten Bit synchronisiert wird
code=0;
newbit=0;
i=0;
delay_ms(80);
enable_interrupts(int_ext);
}
}
} ___________________________
This message was ported from CCS's old forum
Original Post ID: 10947
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Timer0 Problems
PostPosted: Thu Jan 23, 2003 4:09 pm     Reply with quote

<font face="Courier New" size=-1>:=This is a code for manchester decoding !
:=can anyone tell me why the syntax
:=if(count>abtast)
:=..
:=doesn't work ??
:=There i want to ask if the counter value is greater than my scanvalue !?!
:=if(count>10) for instance works, why can't i put there a integer ???
------------------------------------------------------------

If something doesn't work, and you're not sure whether it's
a compiler bug, or if it's your problem, then make a small
test program. Here's an example:

<PRE>
#include "c:\program files\picc\devices\16F877.h"
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT, NOLVP
#use Delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
<BR>
//===============================================
void main()
{
char i;
long count;
long abtast;
<BR>
count = 10;
<BR>
for(i = 5; i < 15; i++)
{
abtast = i;
if(count >= abtast)
printf("abtast = \%ld Count is >= abtast\n\r", abtast);
else
printf("abtast = \%ld Count is < abtast\n\r", abtast);
}
while(1);
}
</PRE>

This program tests the problem that you complained about.
Here is the output on the terminal window:
<PRE>
abtast = 5 Count is >= abtast
abtast = 6 Count is >= abtast
abtast = 7 Count is >= abtast
abtast = 8 Count is >= abtast
abtast = 9 Count is >= abtast
abtast = 10 Count is >= abtast
abtast = 11 Count is < abtast.
abtast = 12 Count is < abtast.
abtast = 13 Count is < abtast.
abtast = 14 Count is < abtast.

That output looks good. It's what I would expect.
I tested this with PCM vs. 3.136.

Whenever you have a problem where you don't understand
something, always make a short test program. That's what
I do. I've done it hundreds of times.
----------------------------------------

With regard to your main program: You still have some
problems in your design. I notice that you disable all
interrupts with "disable_interrupts(global)", but then
you never turn them back on. At the end of your code
you have "enable_interrupts(int_ext)". That line won't
do anything, because you still have GLOBAL interrupts
turned off. I think someone told you this before.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10950
Hans Wedemeyer
Guest







Re: Timer0 Problems
PostPosted: Thu Jan 23, 2003 4:49 pm     Reply with quote

:=With regard to your main program: You still have some
:=problems in your design. I notice that you disable all
:=interrupts with "disable_interrupts(global)", but then
:=you never turn them back on. At the end of your code
:=you have "enable_interrupts(int_ext)". That line won't
:=do anything, because you still have GLOBAL interrupts
:=turned off. I think someone told you this before.

Yes I did, once on this board and once by private email.


I guess he/she is never going to learn or take advice.

It's strange, he/she comes here and we spend time trying to help and it's ignored...

I simply do not understand the attitude !
___________________________
This message was ported from CCS's old forum
Original Post ID: 10953
chriss2000
Guest







Re: Timer0 Problems
PostPosted: Fri Jan 24, 2003 2:13 pm     Reply with quote

hey pcm programmer, you haven't understood my problem, i want to ask if a timervalue wich i get trough "get_timer0()" is greater or smaller than an integer and this doesn't work.


And a few words to hans wedemeyer, i don't want your statements in my posts, this is really childish what you make, stop it.
You are not very helpfull. I just want some help and i can't make anything against people who missundersatand my questions !!

Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 10974
chriss2000
Guest







Re: Timer0 Problems
PostPosted: Fri Jan 24, 2003 3:41 pm     Reply with quote

hey pcm programmer, you haven't understood my problem, i want to ask if a timervalue wich i get trough "get_timer0()" is greater or smaller than an integer and this doesn't work.


And a few words to hans wedemeyer, i don't want your statements in my posts, this is really childish what you make, stop it.
You are not very helpfull. I just want some help and i can't make anything against people who missundersatand my questions !!

Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 10977
Hans Wedemeyer
Guest







Re: Timer0 Problems
PostPosted: Fri Jan 24, 2003 3:53 pm     Reply with quote

Well if you take the advice you ask for instead of ignoring it you will get your program to work.

Remember this board is voluntary and when you contacted me at my private address you did not even have the common decency to say thank you for the time I spent sending you a reply.

Since the you have posted code that several people have commented upon and you ignore the advice....

It is truly strange why you even bother to ask for help.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10978
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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