Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PLEASE HELP! Square wave on 68HC908

Status
Not open for further replies.

chrismac99

New Member
I am an electrical engineer major and I am currently taking a class in microcontrollers. I have a teacher that is not very thorough in his teachings (to say the least) and to top that off, we do not have a textbook to turn to.

The assignment is to "write a program to output a 10khz square wave on timer channel 0" and to fully comment that code. I could figure out the comments on my own but would appreciate it GREATLY if someone could write this [probably simple] code for me. Thanks in advance!
 
I should probably post what I have so far. Its not much, and it may not even be right.

LDA #$34
STA $0020
LDA #AA
STA $0025
LDA #$000A
STX $0026
LDA #$14
STA $0026
 
Since it's your homework assignment are you not the one supposed to write the code?


I am, but like I said I am completely lost. I have been trying to research it online, but came up with close to nothing. Registering and posting on this forum was my last resort, so if I find nothing here I will be forced to take a zero. I can't afford that.

I guess I am looking for any sympathy you may have, and would greatly appreciate any help given. Thanks again.
 
I am an electrical engineer major and I am currently taking a class in microcontrollers. I have a teacher that is not very thorough in his teachings (to say the least) and to top that off, we do not have a textbook to turn to.

The assignment is to "write a program to output a 10khz square wave on timer channel 0" and to fully comment that code. I could figure out the comments on my own but would appreciate it GREATLY if someone could write this [probably simple] code for me. Thanks in advance!


It is due tomorrow. He assigned it monday, because he asked in class for us to do it and no one had an answer for him. He got angry and assigned it for homework. Pretty counter productive teaching method if you ask me.

If you can be of any help I appreciate it. Thanks.
 
Since you don't have a manual or book, download the proper data sheet and study it:
68HC908 datasheet application notes
The first one in the list appears to be German so avoid that one unless you're German. ;)
 
Last edited:
Have you written out pseudo code yet? I am taking a class with the 68HC11 right now and I find that writing the p-code out really helps me organize my program. I am not sure of the difference between the 2 chips, but maybe I can help you out.
 
I am not sure what you mean by pseudo code, but I do know there are A LOT more search results on google for the 68hc11 than the 908. This is very frustrating, I have beenresearching it since this morning.
 
Pseudo code is code that is written in C-like or BASIC-like to help you organize your code.
Example:
while(1)
{
OUTPUT = 1
wait_us(50)
OUTPUT = 0
wait_us(50)
}
 
I have done that, and I know what the program needs to do, I just don't know how to assemble the code to do so. The program has to do with the TIM status and control register
 
Polling is when when you continuously read a register to see if a flag has been set. I do not have any experience with the HC908, so I am not sure if this is going to help you.

All you need to do is write a value into the Timer0 register that corresponds to how long it is going to take for it to overflow. I am assuming that it is a 16bit timer, and you are running a 4Mhz crystal. So, it would take 65535uS for Timer0 to overflow, and generate a timer overflow interrupt. Since we only want to interrupt every 50us, you have to load 65485 into Timer0. Then, just switch the output on or off as required.

I have no idea where these registers are located on the HC908, so I cannot offer any assembly to help you out. If none of the above makes sense to you, I suggest you talk to your instructor, because this assignment seems a little difficult to complete given how little information you were given.
 
Im screwed.

I realize its a simple program, I just do not understand how to assemble my code. I know I need to load the period of the square wave into a register, and have it toggle on and off based on a certain timeframe.

My teacher did not explain any of this to us, so I am completely in the dark.
 
I don't know the freescale micros at all, but I took at look at the data sheet:
**broken link removed**

PWM starts on page 177, and they pretty much tell you how to do it on page 180.

Wish I could be more help for you, but I can't. :(

At least you won't be alone. Sounds like the whole class is in the same boat.:D
 
Thanks beebop.

I found that page about an hour ago, but I don't think thats the way he wants us to write it. He said not to use TIM instead use output/compare to toggle. The language they use on page 180 is foreign to me, so its little help. For steps two and there listed, there are many registers. Do I write the same valuer to all of them? I also dont know if I need buffered or not buffered. Again this is all foreign to me.

Again, thanks for your help everyone.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top