Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Am I going mad?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051
View previous topic :: View next topic  
Author Message
clive

Bascom Member



Joined: 17 Nov 2007
Posts: 2

switzerland.gif
PostPosted: Sat Nov 17, 2007 10:19 pm    Post subject: Am I going mad? Reply with quote

Please help me with a problem I have using Timers.

When I use the following code and simulate it,
I get the right value in variable A (i.e A=1001)

$regfile="reg51.dat"
$crystal=12000000
$noinit
disable interrupts

Dim A as word

Set Tmod.0
Reset Tmod.1

TL0=1
TH0=0

Start Timer0

Waitms 1

A = Counter0

End


But when I use the following code as recomended in the help
file of Bascom, I get a hopelessly incorrect value (A=65535)

$regfile="reg51.dat"
$crystal=12000000
$noinit
disable interrupts

Dim A as word
Config Timer0=counter , Gate=Internal , Mode=1

Load Timer0 , 1
Start Timer0

Waitms 1

A = Counter0

End

What am I doing wrong?
Back to top
View user's profile
Gianni

Bascom Member



Joined: 09 Jul 2004
Posts: 61
Location: Italy

blank.gif
PostPosted: Sun Nov 18, 2007 10:21 am    Post subject: Reply with quote

Please help me with a problem I have using Timers.

When I use the following code and simulate it,
I get the right value in variable A (i.e A=1001)

$regfile="reg51.dat"
$crystal=12000000
$noinit
disable interrupts

Dim A as word

Set Tmod.0
Reset Tmod.1

You can't do that! Tmod is not bit addressable


TL0=1
TH0=0

Start Timer0

Waitms 1

A = Counter0

End


But when I use the following code as recomended in the help
file of Bascom, I get a hopelessly incorrect value (A=65535)

$regfile="reg51.dat"
$crystal=12000000
$noinit
disable interrupts

Dim A as word
Config Timer0=counter , Gate=Internal , Mode=1
I suppose this can't works with simulator
Timer0=counter means you use an external clock at T0 pin
You should use
Config Timer0=timer , Gate=Internal , Mode=1


Load Timer0 , 1
Load works for autoreload mode only
You must use Counter=1


Start Timer0

Waitms 1

A = Counter0

End

What am I doing wrong?
Back to top
View user's profile
clive

Bascom Member



Joined: 17 Nov 2007
Posts: 2

switzerland.gif
PostPosted: Sun Nov 18, 2007 10:41 am    Post subject: I an sane again! (I think) Reply with quote

Thank you, now I know where I went wrong.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-8051 All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum