Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/08/07 14:31
Read: times


 
#147988 - Some thoughts and help
Responding to: ???'s previous message
Hi Nima,

There are many errors in your program. Here are some of them:
  • You really need more comments. This will help others understand what you are doing. Two months from now it will also help you understand what you were doing. Sometimes just the process of writing the comments will help you discover problems.
  • Your interrupt routine uses both A and R4 without saving and restoring them. Do you understand why this is fatal?
  • You carefully set R4 in the interrupt routine, and then never use it anywhere else in your program. That can't be right.
  • As near as I can tell, the only effect of the RAMPUP subroutine is to set TON to 150 and TOFF to about 100. If you actually want it to ramp up the PWM, doesn't it also have to call PWMOUT or something similar?
  • How does your program start? Don't you need a JMP to INIT at location 0?
The fact that there are so many errors here makes me think that you are trying to do too much at once. Try breaking the problem down into smaller pieces and then make each piece work before you go on to the next one. For example, you could work up to the program you are trying to write by taking these steps:
  1. Make a program that simply toggles the output up and down
  2. Modify the program so that the up time and down time are controlled by fixed values for TON and TOFF. Recompile it with different values for TON and TOFF to make sure it works.
  3. Modify the program so that TON comes from the serial port and get that to work.
  4. Add your rampup routine and get that to work.
A question: Suppose you wanted TON to be 32. What character(s) would you send to the serial port to make that happen?

A hint: Check out the CJNE and DJNZ instructions. They are much better for controlling loops than SUBB.

Best of luck.

-- Russ


List of 22 messages in thread
TopicAuthorDate
PWM code thoughts and help?            01/01/70 00:00      
   Some thoughts and help            01/01/70 00:00      
      very good help Russ            01/01/70 00:00      
      cheers!            01/01/70 00:00      
      character for 32            01/01/70 00:00      
         Good            01/01/70 00:00      
      A & R4 fatal occurence            01/01/70 00:00      
         Info on interrupts            01/01/70 00:00      
            Right next to me...            01/01/70 00:00      
               Aha            01/01/70 00:00      
      tell the truth!            01/01/70 00:00      
         Take a few deep breaths            01/01/70 00:00      
            no arteries popping            01/01/70 00:00      
   hows this? :)            01/01/70 00:00      
      Better, but still has problems            01/01/70 00:00      
         running out of subject line ideas            01/01/70 00:00      
            re: running out of subject line ideas :)            01/01/70 00:00      
            Some comments            01/01/70 00:00      
   Interrupts and shared resources            01/01/70 00:00      
   a thought - if it is help is up to you            01/01/70 00:00      
   More on the PWM program            01/01/70 00:00      
      Purpose of my question            01/01/70 00:00      

Back to Subject List