nedd help 16f84


Closed Thread
Results 1 to 6 of 6

Thread: nedd help 16f84

  1. #1
    Join Date
    Apr 2009
    Posts
    36

    Exclamation nedd help 16f84

    i use pic 16f84 and i want to send data by shiftout to the lcd .the problem is i dont know to use the variables for shiftout .i want to write a programe to count or digital clock i use 4 digit leds and ic 74hc164
    this is the code please help
    define _HS_OSC & _LVP_OFF & _WDT_OFF & _CP_OFF
    define _BODEN_OFF & _MCLRE_ON & _PWRTE_ON

    DEFINE OSC 20

    INCLUDE "MODEDEFS.BAS"

    TRISA = %00010000
    TRISB = %00000000
    PortA = $20
    PORTB = 0
    SDO VAR PortB.0
    SCLK var PortB.1

    Digit_1 var byte
    Digit_2 var byte
    Digit_3 var byte
    Digit_4 var byte
    Displays VAR WORD


    Digit_1 = 0
    Digit_2 = 0
    Digit_3 = 0
    Digit_4 = 0

    data @ 0,252,96,218,242,102,182,190,224,254,246

    LOOP:
    COUNT PortA.4,1000,CounterTotal
    DISPLAYS=0
    DISPLAYS=(DISPLAYS+CounterTotal)
    displays=(displays*6)

    gosub Display
    CounterTotal=0
    GOTO LOOP


    Display:
    DIGIT_OUTPUT = DISPLAYS dig 0
    READ DIGIT_OUTPUT, DIGIT_1
    DIGIT_OUTPUT = DISPLAYS DIG 1
    READ DIGIT_OUTPUT, DIGIT_2
    DIGIT_OUTPUT = DISPLAYS DIG 2
    READ DIGIT_OUTPUT, DIGIT_3
    DIGIT_OUTPUT = DISPLAYS dig 3
    READ DIGIT_OUTPUT, DIGIT_4

    shiftout SDO,SCLK,0,[DIGIT_1\8,DIGIT_2\8,DIGIT_3\8,DIGIT_4\8]
    pause 1000

    return

    END

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Well you know good code when you borrow it, http://www.picbasic.co.uk/forum/showthread.php?t=9037
    Now do something with it! Take it apart and see what makes it work.
    Code:
    shiftout SDO,SCLK,0,[DIGIT_1\8,DIGIT_2\8,DIGIT_3\8,DIGIT_4\8]
    there is the statement sending info to the display, SDO & SCK are aliases to ports on the PIC.
    DIGIT_1 DIGIT_2 . . . ARE the variable names containing the information, everything else is just counting and sorting the information. You say and I
    i want to write a programe to count or digital clock i use 4 digit leds and ic 74hc164
    This is not written to work that way, this is written to use SPI style readouts. Go back to that other thread and look at post 6 mister_e's code you will see how to strobe the displays . . . . here is the basic idea, your pic creates a pattern of a number across the output port, and lights 1 display, then repeats with a pattern for the next number and lights it . . . . and it does it so fast you cannot see the dark times.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you very much joe for reply . i didnt inderstand good that code but if you dont mind please i want to know how to use the variable for read ..,b2
    i want to read from 1 to 10 addresses to b2 every 1000 mlscnd 1 byte from data to b2 so the shiftout has pause 1000 then it will count from 0 to 9 on 1 digit so i will understandhow to (vary) between epprom data and b2 example
    this is my last code i wrote now i can read from data to b2 and send it out to the digit but i need to count from 0 to 9 and pause between numbers please thank you so much



    define _HS_OSC & _LVP_OFF & _WDT_OFF & _CP_OFF
    define _BODEN_OFF & _MCLRE_ON & _PWRTE_ON



    DEFINE OSC 4

    Include "modedefs.bas"


    B2 var byte
    SDO VAR PortB.0
    SCLK var PortB.1

    TRISB = 0
    TRISA = 1


    Read 3,b2

    main:

    SHiftOUT SDO,SCLK,0,[B2\8]
    pause 1000
    goto main

    end
    data @ 0,252,96,218,242,102,182,190,224,254,246

    all what i want is to know how to use variables like this so i will inderstand and i can carry on .
    Last edited by malwww; - 2nd May 2009 at 06:13.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    M E Labs ( the maker of your compiler ) has samples, and I think that is where this one came from as it has zero documentation ( as to ownership ). I suggest you look their site over, many samples there.
    Code:
    ' READ and WRITE word variables to on-board EEPROM
    '
    ' Word is used to add 1000 to each location address and store the
    ' result.  The word data must be stored as 2 separate bytes.
    
    
            INCLUDE "modedefs.bas"          ' Include serial modes
    
    SO      VAR		PORTC.6					' Define serial output pin
    
    B1      VAR     BYTE					' Address variable
    W2      VAR     WORD					' Data variable
    
    
    loop:   
    
    		For B1 = 0 To 12 step 2			' Step 2 because each word requires 2 bytes of memory
            	W2 = B1 + 1000          	' Add 1000 to address
            	Write B1, W2.HIGHBYTE		' Write high byte of word
            	Write B1+1, W2.LOWBYTE		' Write low byte of word to next address
    		Next B1
    
    		For B1 = 0 To 12 step 2			' Step 2 to get word size data
            	Read B1, W2.HIGHBYTE		' Read high byte
            	Read B1+1, W2.LOWBYTE		' Read low byte
            	SerOut SO,T2400,[#W2," ",10,13]	' Display the word data
    		Next B1
    		
            SerOut SO,T2400,[10,13,10,13] 	' Skip 2 Lines
    
            GoTo loop                       ' Forever
    you see a for next loop pointing to location in eprom to write or read from.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you joe for helping im doing these examples, and i used buttoms to rite and read in the eeprom till now i will try to learn more well thank you again for helping,

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malwww View Post
    thank you joe for helping im doing these examples, and i used buttoms to rite and read in the eeprom till now i will try to learn more well thank you again for helping,
    Come back after you have tried those with more questions, the more you learn, the better your questions will get, and better teachers will step up.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 16F84 and I2C bus
    By Navaidstech in forum General
    Replies: 2
    Last Post: - 20th March 2009, 16:04
  2. send data from VB 6 to PIC 16f84
    By win_832001 in forum Serial
    Replies: 2
    Last Post: - 9th March 2006, 14:21
  3. how to send data from VB to PIC 16f84
    By win_832001 in forum Serial
    Replies: 0
    Last Post: - 25th February 2006, 16:15
  4. End of the 16F84
    By Squibcakes in forum General
    Replies: 2
    Last Post: - 20th May 2004, 14:40
  5. Replies: 3
    Last Post: - 3rd September 2003, 12:05

Members who have read this thread : 1

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