Need Help! 16F84 7 segment display

Results 1 to 9 of 9

Thread: 16F84 7 segment display

  1. #1
    Registered
    Join Date
    Mar 2009
    Location
    Slovenia
    Posts
    5
    Downloads
    2
    Uploads
    0

    Default 16F84 7 segment display

    Hi,
    I need help on programing a 16F84 in assembler code to make it display hexadecimal values from 0 to F in a range of 0,5 sec with TMR0 on a 7 segment display. I will post some code later.

    Similar Threads:


  2. #2
    Registered
    Join Date
    Aug 2008
    Location
    Australia
    Posts
    7
    Downloads
    0
    Uploads
    0

    Default pic Programming

    Hi The info you need is in the books supplied at this website
    https://www.sq-1.com/
    I have purchased all but a couple of these books and they are brilliant. Wanna be to for the cost to get them to Australia lol. Seriously check it out . The books I would look at buying first are Easy Microcontrol'n and Microcontol'n Apps/ Also check out tutorial 10 on this website http://www.winpicprog.co.uk/pic_tutorial.htm. If you want a specific program written let me know and I will see what I can do? Buy the way also check out www.oshonsoft.com they have excellent pic simulators where you can write the program In MPlab ide then open it up in and see exactley what will happen, has a pretty good range of input and output screens eg lcd, led, 7 seg, switches etc.

    Cheers
    Greg



  3. #3
    Community Moderator Al_The_Man's Avatar
    Join Date
    Dec 2003
    Location
    Canada
    Posts
    24216
    Downloads
    0
    Uploads
    0

    Default

    Also I would have though you would get everything for this off the PicMicro site, all their app notes have sample code?
    Al.

    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.


  4. #4
    Registered
    Join Date
    Mar 2009
    Location
    Slovenia
    Posts
    5
    Downloads
    2
    Uploads
    0

    Default OK

    Thank you for the replies!
    So here is my code. Note the PIC is a 16F628A becuase I dont have a pic16F84 and am testing it with the newer one. The next thing to notice is that I have some trouble with the TMR0 register so I generated a simple loop to simulate the dalay. If some one has the time I would appreciate the help.
    Note allso that I need to make the delay with 16 prescaler and if someone coud explain me what this is.

    Code:
    list p=16f628a
    #INCLUDE <P16F628a.INC>
    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _LVP_OFF
      count1	res	1
      count2	res	1
      count3	res	1
      MOVLW 0X07
      MOVWF CMCON
      BSF  STATUS , RP0
      MOVLW b'00000'
      MOVWF TRISA
      MOVLW b'00000000'
      MOVWF TRISB
      BCF STATUS , RP0
    ;——————————- 
    ZACETEK
      MOVLW	b'00111111' ; 0
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'00000110' ; 1
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01011011' ; 2
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01001111' ; 3
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01100110' ; 4
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01101101' ; 5
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01111101' ; 6
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'00000111' ; 7
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01111111' ; 8
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01101111' ; 9
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01110111' ; A
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01111100' ; b
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'00111001' ; C
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01011110' ; d
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01111001' ; E
      MOVWF PORTB
    call Delay500mS
      MOVLW	b'01110001' ; F
      MOVWF PORTB
    call Delay500mS
      GOTO ZACETEK
      
      Delay500mS
    
    	movlw	.3
    	movwf	count1
    	movlw	.140
    	movwf	count2
    	movlw	.82
    	movwf	count3
    
    dloop1	decfsz	count3,f
    	goto	dloop1
    	decfsz	count2,f
    	goto	dloop1
    	decfsz	count1,f
    	goto	dloop1
    	return
      END




  5. #5
    Registered
    Join Date
    Aug 2008
    Location
    Australia
    Posts
    7
    Downloads
    0
    Uploads
    0

    Default Pic

    What frequency xtal are you using?

    cheers
    Greg



  6. #6
    Registered
    Join Date
    Mar 2009
    Location
    Slovenia
    Posts
    5
    Downloads
    2
    Uploads
    0

    Default

    Im using the internal oscilator with 4MHz



  7. #7
    Registered
    Join Date
    Jun 2009
    Location
    South Africa
    Posts
    3
    Downloads
    0
    Uploads
    0

    Default

    Hi Razer
    The way I see it with a crystal of 4Mhz, it gives you a cycle time of 1/(Fosc/4) , or 1uS.
    The maximum prescaler available is 256, which will leave the maximum TMR0 timeout at a quarter of a millisecond, not really useful if you want 0.5 seconds.
    Added to this, if you want to use timer 0 you will need to use interrupt driven software. At a Microchip seminar one of their inhouse troubleshooting experts said that 90% of PIC firmware problems came from interrupt routines. He advised us to avoid interrupts if at all possible.

    I like using delay routines like you have. If you insist on using the TMR0 you'll have to use a prescaler of 256 on a crystal frquency of 2 kHz.

    The prescaler is defined in the final 3 bits of the OPTION_REG register and clearing bit 3 of the same register to allocate the prescaler to Timer 0. ( ie your code should place the binary string xxxx0111 in OPTION_REG . you determine what replaces the xxxx according to your software requirements)



  8. #8
    Registered
    Join Date
    Aug 2005
    Location
    U.S.A
    Posts
    52
    Downloads
    0
    Uploads
    0

    Default

    James,

    What do you mean by ".....which will leave the maximum TMR0 timeout at a quarter of a millisecond"?

    Do you mean TMR0 will overflow in a quarter of a millisecond with a 256 prescaler?

    I get a different time with my calculations. The timer0 also needs to count to 256 before an overflow.

    TMR0 overflow = (1/(Fosc/4))*256*256 = 65.536 milliseconds. The first 256 in the equation is for the prescaler time divider. The second 256 is the actual TMR0 counting from 0 to 256.

    ~~~~~~~~~~~~~~~~~~~~~~
    You could implement this problem using TMR0 and an interrupt service routine.

    If you change the prescaler from 256 to 16 you get a TMR0 overflow every 4.096 milliseconds.

    TMR0 overflow = (1/Fosc/4))*16*256 = 4.096 milliseconds. Now, if you count the number of TMR overflows to 122 you get a time lapse of about 0.5 seconds. You TMR0 interrupt service routine can count the number of overflows.

    Time lapse = 4.096 * 122 = 0.499712 seconds. (0.06 % error)



  9. #9
    Registered
    Join Date
    Jun 2009
    Location
    South Africa
    Posts
    3
    Downloads
    0
    Uploads
    0

    Default

    Hi Megahertz.
    Thanks for the correction, you're perfectly right.

    The point I was trying to get across is that by using a well set up delay routine , Razer would avoid using interrupt routines.

    I have avoided using interrupts thus far and always had success.

    Thanks for your help.



Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

16F84 7 segment display

16F84 7 segment display