USART+PWM Problem


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default ok

    it is ok friends i will work to make it bymyself and i wills end to this forum my code when it is ok

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by alex-x View Post
    it is ok friends i will work to make it bymyself and i wills end to this forum my code when it is ok
    I don't think anybody here is suggesting that you do it 'by yourself', but a bit of effort on your part wouldn't hurt the effort on anybody else's part...in other words...I can't speak for everybody, but, we'll help you as much as you help yourself...
    So get writing some code...(and put away all the sharp objects within reach )

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    ...(and put away all the sharp objects within reach )
    Look who's talking
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Look who's talking
    My lab is in rework right now (remember the water damage awhile back?)...
    All I've got right now is some good smelling left over paint (wait 'till I post the pictures of the walls) and a bunch of wood that will become work benches...
    I've got lots of sharp objects and power tools within reach...but no electronics to work on...

  5. #5
    Join Date
    May 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default usart

    @Mister_e
    @Skimask

    thanks for help me and look to my code please what is problem on it i have pic 16F877A and i use pbp 2,47 i have found this code int he forum and little designed it back for my Pic16F877A but it is not working i want to dim a led on portc1 (portc1and portc2 is pwm port on 877A pic) i want to dimming it but some probşlem on the code can you look and say what is my problem here?


    '----------------------------------------------------------------------
    INCLUDE "modedefs.bas"
    @ DEVICE HS_OSC
    @ DEVICE pic16F877A
    @ DEVICE pic16F877A, WDT_OFF
    @ DEVICE pic16F877A, PWRT_ON
    @ DEVICE pic16F877A, PROTECT_OFF
    @ DEVICE pic16F877A, BOD_OFF
    '----------------------------------------------------------------------
    DEFINE OSC 20
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 4
    DEFINE HSER_BAUD 250000
    DEFINE HSER_CLROERR 1
    '----------------------------------------------------------------------
    counter VAR word
    idleflag VAR WORD
    dummy VAR WORD
    RCIF VAR byte
    startcode VAR WORD
    aminus VAR WORD
    adresse_grada VAR WORD
    x VAR WORD
    newlevel1 VAR WORD
    '----------------------------------------------------------------------
    TRISB=0
    TRISC=%10000000 ' portc.7 is RX input
    ADCON0=0
    ADCON1=7
    adresse_grada=2


    checkdmx:
    counter = 1
    pulsin portc.7,0,counter ' portc.7 is RX input
    if counter = 0 then
    idleflag = 1
    endif
    if counter < 40 then checkdmx

    dummy = RCREG
    dummy = RCREG
    SPBRG = 0
    TXSTA.2 = 0
    TXSTA.4 = 0
    RCSTA.7 = 1
    RCSTA.6 = 0
    RCSTA.4 = 0
    RCSTA.4 = 1

    while RCIF = 0:wend

    startcode = RCREG

    if startcode <> 0 then checkdmx

    aminus = adresse_grada - 1 'address1 is my target address

    for x = 1 to aminus
    while RCIF = 0:WEND
    dummy = RCREG
    next x

    newlevel1 = RCREG
    pwm portc.1,newlevel1 ,100 'i want dimming a LED on PORTC.1
    RCSTA.7 = 0 'turn off the USART
    goto checkdmx
    return

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by alex-x View Post
    @Mister_e
    @Skimask

    thanks for help me and look to my code please what is problem on it i have pic 16F877A and i use pbp 2,47 i have found this code int he forum and little designed it back for my Pic16F877A but it is not working i want to dim a led on portc1 (portc1and portc2 is pwm port on 877A pic) i want to dimming it but some probşlem on the code can you look and say what is my problem here?

    [code]
    checkdmx:
    .................................................. .........................
    pwm portc.1,newlevel1 ,100 'i want dimming a LED on PORTC.1
    .................................................. .........................
    goto checkdmx
    return
    PWM doesn't run in the background... When you hit a PWM command, that's what you get, one shot, one pulse of PWM, then you loop back and start checking for more DMX data input, which you probably missed because you were trying to do PWM in the first place, and while you are waiting for some DMX data, your LED is off because the PIC isn't executing a PWM command. See how it all ties in together to make a seemingly non-working version of the code?
    And what have you changed and/or tried to change in the code to make it work? Anything?
    What you want is some interrupt driven code...interrupt driven serial input, interrupt driven PWM (or a hardware module, whichever works for you).
    There's too much high speed stuff going on to be handled sequentially... Do a search for Instant Interrupts and Slow Speed Pulse Width Modulation. This code you've 'found' and keep copying probably isn't going to work for you in the end without knowing what's really going on in the first place and how to use interrupts.

  7. #7
    Join Date
    Nov 2004
    Posts
    61


    Did you find this post helpful? Yes | No

    Default DMX512 Source Code

    Turns out that a few months ago, Microchip posted app notes for

    * DMX512 transmission
    * DMX512 reception
    * Software-based 3 color PWM generation

    Granted, it's all written in assembly. And it may not be quite as user-friendly to PBP newbies as DT's Instant Interrupts / SSPWM (very nice, BTW!).

    But they can gather all 512 channels of dimmer data in 27 lines of .asm code. Pretty neat!

    It's elegantly written, very compact and fairly easy to follow. Their write-up on DMX gives a nice overview of the various stages of the signal and what the processor needs to do during each.

    Their trick for generating the break signal on the transmit side is nice, too.

    Their DMX receive code is *not* interrupt based, but the PWM routine is.

    Check out notes #1074 and #1076

    Link:

    http://www.microchip.com/stellent/id...GE&nodeId=2048

    Best,

    JEC

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. byte Tx w/ USART 16f876a problem
    By GargamelDigi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th July 2008, 05:50
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  5. PWM problem CCP2 port
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th September 2006, 23:34

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