Prescaler divider other than 1:1 causes the PWM module in PIC10F322 to stop working.


Yesterday 22:13
Forum: Proton Plus Compiler v3
Starter: gdesantis
Views: 0
Replies: 0
Yesterday 18:35
Forum: The Lounge
Starter: Les
Views: 0
Replies: 11
+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Junior Member SebaG's Avatar
    Join Date
    Sep 2013
    Posts
    24
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    973.96 MB

    0 Not allowed!

    Default Prescaler divider other than 1:1 causes the PWM module in PIC10F322 to stop working.

    For several days I was struggling with the code below and I'm honestly fed up with it - do you see something that I do not see? 2.5V power supply from batteries, fully functional batteries, PIC has been replaced with a new one and still nothing.


    In the program I read the ADC value from the potentiometer slider (ADC_Raw), which I then give as PWM value (Duty).


    For the values given in the code, everything works well, a beautiful PWM is generated with f = 15.6kHz. However, I need PWM with a lower frequency and I wanted to use a TMR2 module prescaler, but any other setting than 1:1 as in the working code below (T2CON = 0x4) causes that the system stops! It does not work, does not generate PWM. I really do not have a concept anymore. What's worse, I can not change the hardware because I'm already soldering on the fabricated PCBs. Do you have any ideas what could be wrong?

    Code:
    Device = 10F322
    
    
    Config FOSC_INTOSC, BOREN_OFF, WDTE_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, LVP_OFF, LPBOR_OFF, BORV_LO, WRT_OFF
    Declare Xtal 4
    OSCCON = 0x50                                                                                                      
    Declare All_Digital On                                                                        
    
    TRISA = 0x4
    PORTA = 0x0
    
    
    Dim Duty As Word
    Dim ADC_Raw As Byte
    
    
    Main:
        GoSub AD_Conv
        GoSub PWM_1 
    GoTo Main
    
    
    '==============================================================================================
    AD_Conv:                                                                                
    '==============================================================================================
        ANSELA = 0x4                                                                    
        ADCON = 0x28                                                                     
        
        ADCONbits_ADON = 1                                                                   
        ADCONbits_GO_DONE = 1                                                              
            While ADCONbits_GO_DONE = 1                                                    
            Wend                                                                             
        ADC_Raw = ADRES                                                                 
        
        ADCONbits_ADON = 0                                                                   
        ANSELA = 0x0                                                                  
    Return
    '==============================================================================================
    PWM_1:                                                                                
    '==============================================================================================
        Duty = ADC_Raw
        PWM1DCL.6 = Duty.0
        PWM1DCL.7 = Duty.1
        PWM1DCH = Duty >> 2
        PR2 = 0x3F
        TMR2 = 0x0
        T2CON = 0x4
        PWM1CON = 0xC0
    Return
    Last edited by SebaG; 29th June 2018 at 19:46.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Pic10f322
    By Dphil7532 in forum Proton Plus Compiler v3
    Replies: 12
    Last Post: 2nd March 2013, 23:07
  2. Compiler stop working. Please, help me
    By hobbykit in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 1st September 2010, 09:14
  3. 18F1330 PWM Module
    By peaps in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 25th April 2008, 21:48
  4. Stop the pic working
    By sgufa in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 5th July 2007, 21:48
  5. interrupts prescaler problem
    By Dphil7532 in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 20th January 2006, 20:21

Members who have read this thread : 17

Actions :  (Set Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts