In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote: Well here is the generated code for PWM rb.0, 128, 3 [code] 168 006B 0CFB MOV FSR,#TRIS_B ; PWM rb.0, 128, 3 006C 0024 169 006D 0400 CLRB IND.0 170 006E 005F MODE $0F 171 006F 0200 MOV !RB,IND 0070 0006 172 0071 0018 BANK $00 173 0072 0C03 MOV __PARAM1,#3 0073 0028 174 0074 0069 CLR __PARAM2 175 0075 0C02 MOV __PARAM3,#2 0076 002A 176 0077 0C41 MOV __PARAM4,#65 0078 002B 177 0079 0C80 ADD __PARAM2,#128 007A 01E9 178 007B 0703 MOVB rb.0,C 007C 0406 0603 0506 179 007F 02EB DJNZ __PARAM4,@$-6 0080 0010 0A79 180 0082 02EA DJNZ __PARAM3,@$-9 0083 0010 0A79 181 0085 02E8 DJNZ __PARAM1,@$-16 0086 0010 0A75 182 0088 0CFB MOV FSR,#TRIS_B 0089 0024 183 008A 0500 SETB IND.0 184 008B 005F MODE $0F 185 008C 0200 MOV !RB,IND 008D 0006 186 008E 0018 BANK $00 187 [/code] Its too late to diasect it completely tonight, but its clear its a triple loop. 1st param is the # of cycles, 2nd param is the accumulator which is incremented by the duty cycle each pass, the carry bit determines the output. 3rd and 4th params, Im not sure of, one of these probably determines the general frequency. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=79861#m80035 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)