16F18313 issue

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,698
I had to migrate to MPLABX now using the later Pic's that allow designating any output for PWM.
An odd occurrence occurs
If I allow the PWM5CON instruction to compile, the PGM appears to halt there, IOW the DetPWMpin routine is not reached.
I proved it out by setting LEDs if it gets past the PWM5 instruction.
It is not a conditional instruction, so any ideas?


Code:
    ;    banksel PWM5CON ; Set bank
    ;    bsf    PWM5CON,PWM5EN ; Enable the PWM5 module,PWM SET   
 
           
DetPWMpin     ;set current PWM output
            btfsc   BackupLAT, 0   ;CurrentLAT,0
            goto    PWM_RA0      ;SETRA0 PWM
            btfsc   BackupLAT,1   ;CurrentLAT,1
            goto    PWM_RA1      ;SETRA1 PWM
            btfsc   BackupLAT,2   ;CurrentLAT,2
            goto    PWM_RA2      SETRA2 PWM
 

JohnInTX

Joined Jun 26, 2012
4,787
Quick hits:
You set the bank for PWM5CON but not back to locate BackupLAT?
Make sure the PWM interrupt is disabled and/or the service routine is correct?
(not looking at the datasheet)
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,698
Quick hits:
You set the bank for PWM5CON but not back to locate BackupLAT?
Make sure the PWM interrupt is disabled and/or the service routine is correct?
(not looking at the datasheet)
Thanks, I assumed that the BackupLAT , which is defined in CBLOCK is in the common RAM which is accessible from all banks?
 

JohnInTX

Joined Jun 26, 2012
4,787
An odd occurrence occurs
If I allow the PWM5CON instruction to compile, the PGM appears to halt there, IOW the DetPWMpin routine is not reached.
I can't see anything from the code snippet that would account for that if BackupLAT is indeed in common RAM 70h-7Fh. Can you step through the code and monitor the program counter to see where it is going? I'd also look carefully at the assembled code binary bits and link map, if applicable, to make sure that the code and addresses you think you have are actually what it built.
Which assembler?

btfsc BackupLAT, 0 ;CurrentLAT,0
goto PWM_RA0 ;SETRA0 PWM

Are you starting the PWM before configuring the output (and other params?)
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,698
I can't see anything from the code snippet that would account that if indeed BackupLAT is in common RAM 70h-7Fh. Can you step through the code and monitor the program counter to see where it is going? I'd also look carefully at the assembled code binary bits and link map, if applicable, to make sure that the code and addresses you think you have are actually what it built.
Which assembler?
As per previous post, I meant to say G.P. Ram 20h - 6fh
So far I haven't managed to use the step-view as you can in MPLAB IDE, I am having to use MPLABX v5.35 unfortunately because of the Pic 16f18313. together with Pickit-3
I have been checking crudely by the progress using LED outputs.
I am going to try and set it up to test according to the book for just one dedicated output to be PWM, rather than what I am trying to do which is swap the PWM module to different outputs every 15secs or so. and get that working first.
 

JohnInTX

Joined Jun 26, 2012
4,787
banksel PWM5CON ; Set bank
bsf PWM5CON,PWM5EN ; Enable the PWM5 module,PWM SET

btfsc BackupLAT, 0 ;CurrentLAT,0
goto PWM_RA0 ;SETRA0 PWM
As per previous post, I meant to say G.P. Ram 20h - 6fh
BackupLAT is in banked RAM? After including the first 2 lines you would be looking for BackupLAT in bank 12 and subsequent code may look in the wrong place as well.
Sorry if I'm missing something..
 

JohnInTX

Joined Jun 26, 2012
4,787
BackupLAT is just a temporary register I assigned located in the general purpose ram. cblock at 0x20
So after banksel PWM5CON you have to do a banksel BackupLAT before those bit tests to reselect bank 0, no?
Sorry to be obtuse. I'm working the original assumption that the code works without the banksel PWM5CON but not with it.
 
Top