Hi Eric, Thanks for that. I'm thinking of writing Vladmir to question this omission. I did see recently on his website, that he was active, or planned to be soon, on supporting Arduinos. Can't wait.hi Steve,
Welcome to AAC.
The PWM feature is not included in the supported peripherals list.
The IDE appears to accept and compile the PWM code, but no signal on the pins or scope.
I'm the same Steve Ian. Unfortunately i don't have a clue on how to write basic routines involving the registers.Hi Steve... If you are the same Steve I've been talking to... Vlad doesn't seem to cover much of the AVR.. But.. All the registers are available.. You could even write high level routines using basic...
Proc pwminit() DDRB = 0x6 OCR1AL = 0x47 OCR1AL = 0x10 TCCR1A = 0xf2 TCCR1B = 0x1a ICR1L = 0x1f '(at 8mhz clock we have: 50 = 8000000 / 8(1 + icr).foc = fosc / prescaler(1 + top)) ICR1H = 0x4e End Proc Proc pwmset(duty As Word) OCR1AL = duty.LB OCR1AH = duty.HB End Proc
Not sure what you intended here Ian, I copied the two procedures to Osh AVR compiler on their own as presented by you and it came up up with error saying procedures must be inserted after end of program. So I wrote a simple program:Just try this for me..
(Ian's two procedures shown here)
Set pwm with the bottom and init with the first.. pwm on pin 9 and 10...
Post the code for your short test program and will check the compiled code to see if the compiler has generated any code for those pWM's
Here it is Eric:
Define CLOCK_FREQUENCY = 8
Dim duty As Word
duty = 255
DDRB = 0x6
OCR1AL = 0x47
OCR1AL = 0x10
TCCR1A = 0xf2
TCCR1B = 0x1a
ICR1L = 0x1f '(at 8mhz clock we have: 50 = 8000000 / 8(1 + icr).foc = fosc / prescaler(1 + top))
ICR1H = 0x4e
Proc pwmset(duty As Word)
OCR1AL = duty.LB
OCR1AH = duty.HB
This is all largely lost on me Eric; are you saying the finger is pointing at Vlad's IDE, and if so, should he be tipped off about it?hi Steve,
Seems to be creating compiled Code, but the IDE will NOT respond to the Code.
Steve1.txt change to .asm...Compiled file
Steve2.txt is the List file
Define CLOCK_FREQUENCY = 8 'Define SIMULATION_WAITMS_VALUE = 0 Dim duty As Word duty = 100 Call pwminit() loop: 'Call pwmset(duty) 'duty = duty + 30 WaitMs 30 Goto loop End Proc pwminit() DDRB = 0x6 OCR1AL = 0xff OCR1AH = 0x0 OCR1BL = 0xff OCR1BH = 0x2 TCCR1A = 0xf3 TCCR1B = 0x0a ICR1L = 0xff '(at 8mhz clock we have: 50 = 8000000 / 8(1 + icr).foc = fosc / prescaler(1 + top)) ICR1H = 0x03 'TIMSK1 = 0x6 End Proc Proc pwmset(duty As Word) OCR1AL = duty.LB OCR1AH = duty.HB End Proc
hi again Ian, first want to say thanks for tacitly telling me I needed to call the procedures in the main program for them to become effective. I didn't know that.Just tried this on an Arduino... got a pulse from .....]
Hi Ian, owe you apology. After having fun and games with this playtime exercise, discovered I was on the wrong pin -10 instead of 9. Still getting some odd results though. When first copying your code andchanging to .pin 9, worked like a dream, slow ramp up in brightness to top value, followed by step drop to minimum. However,after copying your code into another computer, I got the opposte waveform response - step up to max brightness, followed by gentle ramp down to miimum. A mysterious inversion had occurred. Haven't figured it out yet.The ICR1A is 65535 max... But I selected 10 bit.. if you want to use ICR1A as TOP then you need to select a different mode..
Also your example looks like it wants to start at 10000 and reduce... BUT!!! Vlad doesn't use signed numbers so the line
" If duty <= 0 Then duty = 10000 " is useless to you.. Also you need to -5 each loop for the LED to dim.
With the settings you have, ORCA should be 0 ~ 1024.. 10000 is far too high... I set IRCA to 1024 (TOP)..
If you read the datasheet there is a table that will allow several modes of PWM... The one I chose is the easiest for you..
|Thread starter||Similar threads||Forum||Replies||Date|
|Wrongly READ BITs from peripheral, error? Oshonsoft BASIC||Microcontrollers||98|
|HSEROUT intermittent working OSHONSOFT||Microcontrollers||29|
|Oshonsoft libraries ??||Microcontrollers||19|
|Using INCLUDES, FUNCTIONS PROCEDURES and SUBROUTINES in Oshonsoft||Microcontrollers||97|
|Adding BYTEs into a STRING Oshonsoft BASIC||Microcontrollers||39|
by Lianne Frith
by Jake Hertz