atmega16 ck

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello everyone,

i just tried the attached code in Bascom-avr and the led blinked each 4 seconds.

i used the $crystal = 8000000 and waitms  500.

what did i mess to make it blink each half second.

$regfile "m16def.dat"
$crystal = 8000000

Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
Config Lcd = 16 * 4
Config Portd.6 = Output : Portd.6 = 0

Cls
Lcd " ayman"

Do

   Set Portd.6
   Waitms 500
   Reset Portd.6
   Waitms 500

Loop
End

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ayman89 wrote:
i used the $crystal = 8000000 and waitms 500. what did i mess to make it blink each half second.

Just because you say "crystal" is 8000000 does not mean that your AVR is actually running at that speed.  [If you say $crystal = 1234 then you are running at 1.234kHz?  No.]

 

Look in the datasheet for Default Clock Source.  What does it say?  For your model, it will be 1MHz.

 

If you have a crystal or other clock source then you must use the fuses to select that clock source.

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for your reply,

can i change the fuses through bascom, or through programmer?

Last Edited: Fri. Oct 19, 2018 - 02:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

https://www.mcselec.com/index.ph...

 

You will need to seek support for that at the Bascom support. 

Fuses are normally set using your programmer, but ask here if your fuse values are correct BEFORE you attempt to set them or you may brick your chip.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As it seems you are just starting out, why not just tell Bascom the speed your chip is running at, 1MHz?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thats what i'm doing now, and i think my programmer doesn't support changing fuses so i'm also about to build usbasp programmer.

but can i get some advice about in which applications i have to use more than 1 Mhz or ever external oscillator.

 

thanks