Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

TIFR1_ARDUINO UNO

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

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Sat Jun 06, 2020 7:09 pm    Post subject: TIFR1_ARDUINO UNO Reply with quote

Hello Bascom friends !!!
Suppose we have our Arduino Uno card with a frequency of 16 Mhz and Prescaler at 256

Maximum timeer period (ms) = (65536)(256) / 16000000 = 1.0486 = 1048 ms

Old Bascom worked like this TIFR.x
x=0 for timer0
x=2 for timer1

Currently bascom 2.0.8.2

TIFR1
It does not mark error but it compiles well but my Arduino card does not flash led Pb.5

My simple code is this.

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack=40
$swstack=16
$framesize=32



Baud = 9200


Config Timer1 = Timer , Prescale = 256
Start Timer1




Config Portb.5 = Output

Led Alias Portb.5


Do
   If TIFR1=1 then
      TIFR1=1 : toggle led
   End If
loop

End
 



If I change TIMER1 for this, my Arduino Uno card works.

Code:
Do
   If Timer1 = 1 Then
      Timer1 = 1 : Toggle Led
   End If
loop
 


For 1000 ms exact it would be 62500 my Arduino board works well.

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack=40
$swstack=16
$framesize=32



Baud = 9200


Config Timer1 = Timer , Prescale = 256
Start Timer1




Config Portb.5 = Output

Led Alias Portb.5


Do
   If Timer1 = 62500 Then
      Timer1 = 0 : Toggle Led
   End If
loop

End
 


Why does TIFR1 not work? Shocked Shocked Shocked
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 338
Location: Japan

japan.gif
PostPosted: Sun Jun 07, 2020 4:01 am    Post subject: Reply with quote

Code:

Do
   If Tifr1.tov1 = 1 Then
      Tifr1.tov1 = 1 : Toggle Led
   End If
loop
 

If you need 1Hz
Code:

   Config Timer1 = Timer , Prescale = 1024 , Clear Timer = 1
   Compare1a = 15625 - 1

   Do
      If Tifr1.ocf1a = 1 Then
         Set Tifr1.ocf1a
         Set Led
         Waitms 100
         Reset Led
      End If
   Loop
 
Back to top
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Sun Jun 07, 2020 5:07 pm    Post subject: Reply with quote

thanks O-Family
you are such a great geniour
love this forum. Go !!!! Very Happy
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO 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