PDA

View Full Version : Can someone help me get hpwm working on 18f24k22



jimseng
- 21st March 2012, 12:24
Hello.
I am trying to get 3 hpwm outputs on a pic18f24k22. The problem is that it requires reading the data sheet. I can read it but for the life of me I don't understand much of it. Perhaps someone could explain which settings I need for one ccp and then maybe I can work the rest out. I think it is time I learned how to read data sheets but it is so overwhelming and my brain has started to dribble.

Thanks

Demon
- 21st March 2012, 12:57
Bruce has some code in this thread:
http://www.picbasic.co.uk/forum/showthread.php?t=7095

Robert


EDIT: I tried to find better examples using search for HPWM CONFIG sorted by descending date, found this one:
http://www.picbasic.co.uk/forum/showthread.php?t=15829

jimseng
- 21st March 2012, 13:23
Actually, my usual stumbling about blindly programming I thought I would try this and it works. I thought I had to set things up first and I don't understand why I don't but hey. It work so I suppose I should be happy. I kinda wanted to be forced to learn how to read data sheets but now I don't have to for this project at least.
OSCCON = %1110000
TRISC = %00000000
TRISB = %00000000
DEFINE OSC 16
bright var byte


mainloop:

for bright = 254 to 0 step -1
hpwm 1,bright,1000
hpwm 2,bright,1000
hpwm 3,bright,1000
pause 5
next
goto mainloop

Demon
- 21st March 2012, 13:31
My guess is that you fell on a PIC that had default settings exactly the way you needed it. I wouldn't bet on that happening a lot. :D

I know, the 18F have so many features, so many settings. It's a good thing several post sample code.

Also, I stopped using LIVE SEARCH and now use ADVANCED SEARCH. There were times when stuff didn't show up in live search, and advanced search can sort by descending date. That helps in getting the latest posts up front.

Robert