My first foray into PWM


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    how to flash a pulse led @ 1 hz on a pic18 @64mhz with no code overhead and no interrupts

    for demon
    Code:
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 29/11/2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :   pic18f45k20                                                *
    '*          :                                                 *
    '****************************************************************
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRT = OFF
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 18
      CONFIG  WDTEN = ON
      CONFIG  WDTPS = 512
      CONFIG  CCP2MX = PORTC
      CONFIG  PBADEN = OFF
      CONFIG  LPT1OSC = OFF
      CONFIG  HFOFST = ON
      CONFIG  MCLRE = ON
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
    
      define OSC 64
      
       osccon=$70   '4 mhz
        
         trisc=%11111001
      
       trisd.1=0   ' another led 
         T2CON = $4; // tmr2 prescale 0 and on
         PR2 = 255; // pwm period   ?
         CCP1CON = $c; // pwm mode
         CCPR1L = 127; // pw
         t1con=$43
         CCP2CON = 2
         t3con=3
         OSCTUNE.6=1 
    
       ; ccp1 out connects to t1ck in and pulse led connected to ccp2 out
       ; on     pic18f45k20  ccp1 out = portc.2
       ;                     ccp2 out = portc.1  
       ;                     ti ck in = portc.0
    
     
    
     
      
      
      
        
    Main:
      latd.1= !latd.1       ;flash another led
      pause 500
      goto main

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Neat, first I have to get my Charlie-plex going again. I broke it. LOL

    Robert

Similar Threads

  1. Replies: 1
    Last Post: - 4th March 2013, 21:57
  2. PWM to 0-5V
    By tallen in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th April 2010, 08:03
  3. help with pwm
    By babatundeawe in forum Schematics
    Replies: 6
    Last Post: - 30th October 2008, 12:35
  4. Pwm
    By xobx in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th February 2008, 06:33
  5. Pwm
    By JARI NETWORKS in forum mel PIC BASIC
    Replies: 4
    Last Post: - 1st September 2006, 06:03

Members who have read this thread : 0

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