How to convert float point into microsecond?

Write a microcontroller program to generate a pulse train of 1 MHz with 50 % duty cycle?

feels like your homework for tonight :slight_smile:

yeah..help me bro

Where exactly does floating point come into this? Would likely best be done with one of the timers.

could you give the fullsolution????badly need answer

@siam17,

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

Should paid consultancy suit it better?

Do you own an Arduino UNO Board?

I guess it makes sense that people looking to commit plagiarism are so lazy that they even post the assignment they're trying to cheat on verbatim. They don't even bother rewording it to hide their intent.

Can 1 MHz signal be generated using TC0 or TC2?

OK, I did it.

Me too !

What do I win?

Nothing!
@missdrew beat you to it!

I thought I could have the chocolate medal :slight_smile:

Too late - I ate it! Mmmm

:slight_smile: :grinning:

1 Like

I like the assignment. The teacher/professor wants you do dig deep into a microcontroller and read a datasheet. It might take a few days to study the datasheet and read online tutorials.

Most microcontrollers have hardware timers. The Arduino Uno with the ATmega328P microcontroller has three hardware timers. Timer0 is in use by Arduino, so you can use Timer1 and Timer2.

It is also possible in software. The ATmega328P can do very precise timing with output pins in software. There is even a function "__builtin_avr_delay_cycles" for precise clock-accurate delay. Turn off the interrupts for a smooth 1MHz.

I don't know if the Arduino tone() function can output 1MHz, perhaps not. Some libraries can do that, such as the ToneAC library.

Wokwi can simulate a Arduino Uno and has a simulated Logic Analyzer. It is possible to capture the 1MHz and analyze the signal to check if it is really 1MHz.

I suggest to impress your teacher/professor and do all three things. Mention the sources that you use, including a link to this topic.

It was a question. My answer would be "no".

I think OP will wake up if he sees some codes posted by someone?

They might have figured out that they can get answers by just Googling on the thread title:
https://www.google.co/search?q=microcontroller+program+to+generate+a+pulse+train+of+1+MHz