Code conversion C to Assembly.

Ron314

Joined Mar 14, 2023
21
Also, I'd switch to MPLAB X IDE v 5.20, I personally found v5.35 to be flakey when programming in Assembly language on some microcontrollers. Are you using Pickit 2,3 or 4?
 

Ian0

Joined Aug 7, 2020
13,132
I'm taking advantage of the fact that the hardware allows a left justified 10 bit word to control the PWM duty cycle. The bottom 6 bits are ignored. fine_duty_ctr is a 4 bit counter that decides when bit 7 of the PWM is toggled to a 1.
I remember that PWM register now - it's a while since I last used a PIC.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
30,659
Microchip doesn't make a PIC 16F18131. Perhaps you could recheck that part number.
Sorry, it is 16F18313 I have Pickit 2 & 3, P3 requires powering up in the right sequence, in order to get it to connect in v8.92.
Cannot access any kind of assembly debug routines in V5.35 o_O
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
30,659
Max, I suppose you're used to working in assembly, but I can't imagine programming without a compiler.
I can compile the code in V5.35, just that I cannot find any way to use what in V8.92 is the 'Watch' screen to monitor registers etc while stepping thro code.
 

Ron314

Joined Mar 14, 2023
21
I've never used the PWM module in these microcontrollers so now you've given me a reason to dim the lights with it. cool.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
30,659
I've never used the PWM module in these microcontrollers so now you've given me a reason to dim the lights with it. cool.
The only reason I am using the eight pin 16f18313 for PWM, is I need to re-assign the PWM output to different pins each few seconds.
 

trebla

Joined Jun 29, 2019
599
I can compile the code in V5.35, just that I cannot find any way to use what in V8.92 is the 'Watch' screen to monitor registers etc while stepping thro code.
You can add a register from menu Debug>New Watch. You can also view PIC memories under Window>Pic Memory views
 

nsaspook

Joined Aug 27, 2009
16,322
I've never used the PWM module in these microcontrollers so now you've given me a reason to dim the lights with it. cool.
There's so many different things you can do with PWM from playing simple audio clips to modifying the audio attack, level, decay profile of a simple fixed frequency buzzer for different types of chirps or clicks.
 
Top