High Speed Serial Comm PC - PIC and PIC - PIC


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Hi. Thanks once again for all your help!!! With all the info you gave me, I was able to compile some program to transfer 8 bytes using USART, to another PIC and perform PWM to them (not multiplexing yet)
    I have not been able to try the code out yet, because I do not have two 16F877A right now. Anyway here are the TX and RX codes. Im sure they have quite a lot of errors, but a start is a start, isnt it??
    (Please check also the regs at the beginning, I wasnt sure of some bits...

    This is the TX code:

    DEVICE 16F877A
    ALL_DIGITAL = TRUE
    XTAL = 20

    DIM PWMDATA[8] AS BYTE 'VARIABLES FOR DATA TRANSMISSION

    'LOAD PWMDATA FROM SOMEWHERE ELSE...

    DIM INDEX AS BYTE 'INDEX FOR DATA RECEPTION FOR PWMDATA
    DIM X AS BYTE

    TXSTA = %00100110 'ASYNCHRONUS, HIGH SPEED, TRANSMISSION ENABLED.
    RCSTA = %10010000 'USART ON, 8-BIT, NO ADRESS DETECTION, CONTINOUS RECEIVE
    SPBRG = %00001010 'SET BAUDSPEED TO 113200 (HOW DO YOU CALCULATE THE ERROR?)

    MAIN:
    FOR INDEX = 0 TO 7
    TXREG = PWMDATA[INDEX]
    WHILE TXIF = 0 : WEND
    NEXT INDEX
    GOTO MAIN

    /////////////////////////////////////////////////////////////////////////////

    And this is the RC code:

    DEVICE 16F877A
    ALL_DIGITAL = TRUE
    XTAL = 20
    TRISD = $00

    DIM PWMDATA[8] AS BYTE
    DIM INDEX AS BYTE
    DIM X AS BYTE

    FOR X = 0 TO 7 'INITIATE PWMDATA
    PWMDATA[X] 0 = 255
    NEXT X
    INDEX = 0

    TXSTA = %00100110 'ASYNCHRONUS, HIGH SPEED, TRANSMISSION ENABLED.
    RCSTA = %10010000 'USART ON, 8-BIT, NO ADRESS DETECTION, CONTINOUS RECEIVE
    SPBRG = %00001010 'SET BAUDSPEED TO 113200 (HOW DO YOU CALCULATE THE ERROR?)

    MAIN:
    PORTD = $FF
    FOR X = 0 TO 255
    IF X = PWMDATA[0] THEN CLEAR PORTD.0
    IF X = PWMDATA[1] THEN CLEAR PORTD.1
    IF X = PWMDATA[2] THEN CLEAR PORTD.2
    IF X = PWMDATA[3] THEN CLEAR PORTD.3
    IF X = PWMDATA[4] THEN CLEAR PORTD.4
    IF X = PWMDATA[5] THEN CLEAR PORTD.5
    IF X = PWMDATA[6] THEN CLEAR PORTD.6
    IF X = PWMDATA[7] THEN CLEAR PORTD.7
    IF RCIF = 1 THEN GOSUB RECEIVE
    NEXT X
    GOTO MAIN

    RECEIVE:
    IF INDEX = 8 THEN INDEX = 0
    PWMDATA[INDEX] = RCREG
    INDEX = INDEX + 1
    RETURN



    Thanks for all your help!!!
    Manuel

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manumenzella View Post

    DEVICE 16F877A
    ALL_DIGITAL = TRUE
    XTAL = 20

    DIM PWMDATA[8] AS BYTE 'VARIABLES FOR DATA TRANSMISSION

    DIM INDEX AS BYTE 'INDEX FOR DATA RECEPTION FOR PWMDATA
    DIM X AS BYTE

    DEVICE 16F877A
    ALL_DIGITAL = TRUE
    XTAL = 20

    DIM PWMDATA[8] AS BYTE
    DIM INDEX AS BYTE
    DIM X AS BYTE

    PWMDATA[X] 0 = 255

    Manuel
    That's some of the strangest PBP I've seen in awhile...must be that new version...

  3. #3
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Hi. Yes I know. I don't know why my compiles uses those commands. A relative of mine taught me basic and he tought to me like that. Is it at least readable by you guys??? I hope so!!!
    Manuel

  4. #4
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Hey by the way, in the RC code, there is an extra 0 that should be there.
    Instead of :

    FOR X = 0 TO 7 'INITIATE PWMDATA
    PWMDATA[X] 0 = 255
    NEXT X
    INDEX = 0

    It should be:

    FOR X = 0 TO 7 'INITIATE PWMDATA
    PWMDATA[X] = 255
    NEXT X
    INDEX = 0

    Thanks
    Manuel

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manumenzella View Post
    Hi. Yes I know. I don't know why my compiles uses those commands. A relative of mine taught me basic and he tought to me like that. Is it at least readable by you guys??? I hope so!!!
    Manuel
    Maybe because it's not PBP?

  6. #6
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Ohhh Youre right! This was my uncle computer and he left the compiler installed!!! It says PBP compiler, but in About... it says proton!!!!!!!!!!!!!!!!!
    Its quite similar though. The language, i mean.
    Manuel

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Thanks Henrik

    Hi,

    Thanks Henrik for correcting me.

    BTW manuel could you please describe your project in a little bit more detail.
    Regards

    Sougata

  8. #8
    Join Date
    Jan 2007
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Hi. Yes of course. Im sorry i didnt before.
    What I want to do is a 4x4x4 RGB LED cube that is commanded, via serial, from a computer. Each color of each RGB LED will be PWMed (4 bits) so I would need to receive 96 bytes (4 bits per LED).
    Right now, instead of using a computer to send the data, I would like to try to do it with another PIC, so as to simplify it for now.
    Thanks again!!!
    Manuel

Similar Threads

  1. Replies: 11
    Last Post: - 12th July 2008, 02:36
  2. Pic to pic interrupt ans serial comm
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2008, 22:43
  3. pc to pic serial comm and i2c eeprom
    By elektroline in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd November 2006, 05:51
  4. Replies: 5
    Last Post: - 20th March 2006, 01:34
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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