first project, and yes, doesn`t work


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default no blinking

    Hi Shane....i will like to get to the "T1CON settings" part...but, right now i coudn't even make one stupid LED to blink by the external osc (i`m sure i missing something with the ext osc configuration)

    I saw in your post (DT Interrupt and Elapsed Time Running Slow) you use internal 8 MHz OSC....what about if you want to use ext osc...how you will change the T1CON settings ?

    Thank you for the heads up

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Bogdan, this code you wrote isn't too hot...

    blink_LED:

    PORTA.1 = 1
    PAUSE 1
    PORTA.1 = 0

    GOTO blink_LED

    You're turning your LED on for 1mS and then IMMEDIATELY turning it off again... so your eye will probably see your LED ON all the time, but certainly my eye can't catch a blink where the ON state is 1mS and the OFF state is a couple of uS.

    Correct that to something like...

    blink_LED:

    PORTA.1 = 1
    PAUSE 250
    PORTA.1 = 0
    PAUSE 250

    GOTO blink_LED

    Also, another mistake you made, you want PORTA.7 to be an INPUT, by stating PORTA=%00000000 you're forcing it to be an OUTPUT, delete that line.

  3. #3
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Another thing I have a question on, you are using a 32khz crystal. I believe PBP defaults to 4 mhz unless something is Defined for OSC speed.

    DEFINE OSC 8

    for 8Mhz clock.

    Without that I don't know if PBP would know what to do?

    I don't know that 32 khz can be defined in PBP? Some one else that knows more than me might have some better input?

    Shane

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bogdan View Post
    ...but, right now i couldn't even make one stupid LED to blink by the external osc (i`m sure i missing something with the ext osc configuration)
    External Oscillator ? Are you using an external oscillator ? Or are you using a crystal and caps , or a 3 pin resonator ? I ask, because you mentioned the caps. . . and a crystal with caps / or 3 pin resonator will use a different setting in the config statement from an external oscillator.
    EDIT: OK I looked closer at your code and schematic, I think your config should be :
    Code:
    @ __config _LP_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _BOD_OFF & _IESO_OFF  & _FCMEN_OFF & _CP_OFF & _CPD_OFF
    The data sheet indicates to use LP_OSC for 32khz
    Shane: Osc set by oscon register
    Last edited by Archangel; - 27th April 2009 at 08:45.
    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
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Joe S.

    So from the data sheet:

    "LP Oscillator mode selects the lowest gain setting of the
    internal inverter-amplifier. LP mode current consumption
    is the least of the three modes. This mode is designed to
    drive only 32.768 kHz tuning-fork type crystals (watch
    crystals)."

    The OSCON and Config is setting to LP. I was under the impression that PBP needed a "DEFINE OSC" so it know's what speed things are running at?

    Is that not the case?

    Bogdan: Another thing you might try is using the interal OSC for testing, at least to get a light to blink so you know the Pic is working.

    Shane

  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 ShaneMichael View Post
    Joe S.

    So from the data sheet:

    "LP Oscillator mode selects the lowest gain setting of the
    internal inverter-amplifier. LP mode current consumption
    is the least of the three modes. This mode is designed to
    drive only 32.768 kHz tuning-fork type crystals (watch
    crystals)."

    The OSCON and Config is setting to LP. I was under the impression that PBP needed a "DEFINE OSC" so it know's what speed things are running at?

    Is that not the case?

    Bogdan: Another thing you might try is using the interal OSC for testing, at least to get a light to blink so you know the Pic is working.

    Shane
    Honestly Shane, I do not know for sure.
    As I understand it the define is used to synchronize PBP's timing with the assembler's, but I think it only accepts Integer numbers and then only certain ones. A Good question for the EXPERTS. I will have to read up on this . . .
    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.

  7. #7
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default start from zero,... again

    I really appreciate your help guys.

    Melanie: ...i know, the code wasn't hot at all, you right, the second PAUSE xxx should be there (i miss that), ... about the PORTA=%00000000 you're forcing it to be an OUTPUT i didn' know...Thank You

    Shane: ... i tried to blink it by the internal oscillator and is working, but by the ext crystal (32khz) still doesn'work

    Joe: ...i don't think i have to use DEFINE, because i already setup the fuse @ __config _LP_OSC

    Please let post first the schematic and the code and after that take a look at my questions (please):

    schematic:
    Name:  04_07_post.JPG
Views: 1554
Size:  160.8 KB

    code:
    @ __config _LP_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _BOD_OFF & _IESO_OFF & _FCMEN_OFF & _CP_OFF & _CPD_OFF
    '--------------------------------------------------------------------------
    CLEAR 'Set all ram registers to zero
    '--------------------------------------------------------------------------
    'MCU CLOCK SOURCE

    OSCCON.0 = 0 'EXTERNAL osc is used for sys clock (SCS bit)

    '--------------------------------------------------------------------------
    'PORTS CONFIGURATION

    ANSEL=0
    TRISA = %10000000 'set PORTA.7 (T1OSI=XTAL) to input
    TRISB = %00000000
    TRISC = %00000000



    PORTB=%00000000
    PORTC=$00000000
    '--------------------------------------------------------------------------
    PORTB.6 = 1 'JUST FOR TEST

    blink_LED:
    PORTA.1 = 1
    PAUSE 250
    PORTA.1 = 0
    PAUSE 250
    GOTO blink_LED

  8. #8
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default the questions

    1 -it will be enough to setup the fuse @ __config _LP_OSC and to setup the programmer (melabs U2 Programmer ) to update by itself the "Configuration From File" ?....or i have to comment the *.inc file also?
    Name:  04_07_post2.JPG
Views: 1313
Size:  17.0 KB

    2A -how should i setup the TRISA.6 and TRISA.7 when the external crystal is used for sys clock
    2B -what about if i will use internal osc (INTOSCIO) for sys clock and the external crystal for Timer1 ?
    Name:  04_07_post3.JPG
Views: 1300
Size:  33.1 KB


    3 -in the datasheet they say :"LP Oscillator mode selects the lowest gain setting of the internal inverter-amplifier. LP mode current consumption
    is the least of the three modes. This mode is best suited to drive resonators with a low drive level specification, for example, tuning fork type crystals."

    ...they say "A series resistor (RS) may be required for quartz crystals with low drive level."
    Name:  04_07_post4.JPG
Views: 1581
Size:  44.8 KB

    .... so do you think i should add one resistor there ?

    I saw the study case for pic16f690 and ext crystal ([HTML]http://ww1.microchip.com/downloads/en/AppNotes/91097A.pdf[/HTML])... should i go so deep ?

    I have alot more questions, but tomorrow i have to go to work guys.

    Thank You again for your patience.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bogdan View Post
    Joe: ...i don't think i have to use DEFINE, because i already setup the fuse @ __config _LP_OSC
    That was Shane . . .
    Quote Originally Posted by ShaneMichael View Post
    Another thing I have a question on, you are using a 32khz crystal. I believe PBP defaults to 4 mhz unless something is Defined for OSC speed.

    DEFINE OSC 8

    for 8Mhz clock.

    Without that I don't know if PBP would know what to do?

    I don't know that 32 khz can be defined in PBP? Some one else that knows more than me might have some better input?

    Shane
    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.

  10. #10
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Do they make a data sheet for dummies? I could use one. So reading the data sheet I noticed this statement:

    "6.4 Timer1 Oscillator
    A low-power 32.768 kHz crystal oscillator is built-in
    between pins OSC1 (input) and OSC2 (amplifier
    output). The oscillator is enabled by setting the
    T1OSCEN control bit of the T1CON register. The
    oscillator will continue to run during Sleep.
    The Timer1 oscillator is shared with the system LP
    oscillator. Thus, Timer1 can use this mode only when
    the primary system clock is derived from the internal
    oscillator or when the oscillator is in the LP mode. The
    user must provide a software time delay to ensure
    proper oscillator start-up."

    So by that statement I believe you want to use the internal OSC, I'd use it at 4 or 8 mhz.

    Timer one you would use the external crystal and set T1OSCEN =0 so you don't turn on the interal 32.768 crystal....I think? Like I said, I need a data sheet for dummies...

    I'd take on one thing at a time, get the pic working on the internal clock first. When you have a good handle on that then take on clocking Timer one from the crystal. Then as it breaks, you'll know what setting did it.

    Also, if it has an internal crystal at 32.768 khz, why use an external, is it just an accuracy concern?

    I don't think you'll need to dig any deeper than you already are, it's just a matter of getting the correct settings.

    Good Luck,
    Shane

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