PDA

View Full Version : Is it possible to feed PBP variable data into ASM code fragment?



CuriousOne
- 9th July 2017, 17:35
I need to control built in HPWM of PIC16F1825 with PBP. The problem is, that HPWM statement on each execution, stops and restarts HPWM module, which is not desirable. If I issue ASM statement, I can change HPWM generator frequency, without stopping it. But the problem is, that I can't feed required frequency from PBM to ASM code insert into it. So maybe it is possible to locate somehow variable data storage address in PBP, and read it using ASM code, so I can control HPWM as I want?

aerostar
- 9th July 2017, 18:34
Have a look here

http://www.picbasic.co.uk/forum/showthread.php?t=3072

Art
- 12th July 2017, 15:47
If you pause this in the right places it shows how to turn HPWM on & off with inline asm compiled with the PBP code,
but you don’t even have to do that since PBP can write values to the chip registers itself with it’s own variables.
You do it when you, for example, set CMCON = 7 to turn 16F628 analogue ports digital.

https://www.youtube.com/watch?v=KMFNrExf2sc.

CuriousOne
- 13th July 2017, 05:27
Have no access to PBP right now, so construction like this:

FOR A=1 TO 200
CMCON1=A
NEXT

will work?

HenrikOlsson
- 13th July 2017, 10:36
Yes, it will "work" in the sense of assigning the values 1 thru 200 to CMCON1, one after the other.
If that's actually what you want is another matter.

And back to the topic of HPWM. It's easy enough to control the CCP module directly without using the HPWM command, plenty of examples on that floating around here. And, as have been pointed out, any variable you declare in your PBP program can be accessed from assembly by preceding it with an underscore - subject to bank switching etc.

/Henrik.