Read the newbee threads, 16F877A no go.


Closed Thread
Results 1 to 40 of 40

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Unfortunately you can't use DEFINE OSC 11

    all available crystal speed are 3(3.58) 4 8 10 12 16 20 24 25 32 33 40

    so this is one part of your problem. You'll use a DEFINE OSC of 10 or 12. Yep, all the timing will have to be adjusted by yourself but it's not a so much big deal.

    to make it work properly, i'll suggest you use the internal USART modules and the dedicated TX/RX pins. Try something like
    Code:
    DEFINE OSC 10
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 71 ' 9600 Bauds @11.0592 MHZ
    DEFINE HSER_CLOERR 1
    
    Start:
          Hserout ["Serial comm test @9600 bauds",13,10]
          pause 500
          goto start
    about now???
    Steve

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

  2. #2
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Default Serial port

    Hi again.
    I'll try that, saw similar code to that in another place. One of the interesting things was recalling reading that decimal could be written normally ie. 255, bin used %11111111, hex used $FF, but I didn't think 24h was acceptable (in this flavor of picdom anyway).

    I did try:

    DEFINE HSER_BAUD 9600
    DEFINE HSER_TXSTA 36

    Start:
    Hserout ["Bob Port Test",13,10]

    END
    '--------------------------------------

    And I tried commenting those out, including the defines, changing PC baud to 2400 and using:

    ' Read and write hardware USART

    B1 var byte

    ' Initialize USART
    TRISC = %10111111 ' Set TX (PortC.6) to out, rest in
    SPBRG = 25 ' Set baud rate to 2400
    RCSTA = %10010000 ' Enable serial port and continuous receive
    TXSTA = %00100000 ' Enable transmit and asynchronous mode


    ' Echo received characters in infinite loop
    loop: Gosub charin ' Get a character from serial input, if any
    If B1 = 0 Then loop ' No character yet

    Gosub charout ' Send character to serial output
    Goto loop ' Do it forever

    ' Subroutine to get a character from USART receiver
    charin: B1 = 0 ' Preset to no character received

    If PIR1.5 = 1 Then ' If receive flag then...
    B1 = RCREG ' ...get received character to B1
    Endif

    ciret: Return ' Go back to caller

    ' Subroutine to send a character to USART transmitter
    charout: If PIR1.4 = 0 Then charout ' Wait for transmit register empty

    TXREG = B1 ' Send character to transmit register

    Return ' Go back to caller
    '--------------------------------

    And a few others that probably not worth including here.
    I'll let you know how the code you sent works.

    Best Regards,
    Bobby

  3. #3
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Default Reply to Melanie.

    Hi,
    I really don't want to offend, especially having recently contributed to at least one of the royalty checks, but buying and using have so far been different animals.

    I still hope to do something useful with PICs. Thank you for responding.

    Let me help illustrate my frustration.

    >DEFINE OSC 11 is an illegal setting.

    Where does any documentation say that ?

    I probably would have noticed if somewhere it said:
    THE ONLY ACCEPTABLE CLOCK SPEEDS ARE, 3(3.58) 4 8 10 12 16 20 24 25 32 33 40

    The datasheet calls out many configuration bit switches that are not addressed in the .inc file.

    >For 18F series...

    For the 16F877A, the datasheet calls out many configuration bit switches that are not addressed in the c:\pbp\16F877A.INC file, when using PM.

    I only used MPASM for a short while when trying to get the toggle program to work targeting an 18F6520, I didn't need to change MPASM .inc file to get it to load and run. It loaded with some minor complaining about configuration bits, the MPASM and the 18F test aren't the issue currently.

    It's trying to get all of an 16F877A based development borad's basic functions exercised to have a basis to develop custom applications.
    I have gotten a program to run, the LCD to display, a 7 segment LED to work, and 3 analog channels to read.
    I haven't got the PIC to start without having to press the reset again, when the original program that came in the PIC starts fine, and I haven't been able to get a readable serial port output, nor have I seen the input function work.

    Best Regards,
    Bobby

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


    Did you find this post helpful? Yes | No

    Default

    i always use MPASM too. As i often switch for 16XXX to 18XXX i don't want to spend time by switching PM to MPASM and such.

    So just comment the PBP default fuse as i described in the FAQ post and try this.
    Code:
    @ __config _HS_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF                  
        ' XT (4Mhz) oscillator
        ' Enable watch dog timer
        ' Enable power up timer
        ' Enable brown out detect
        ' Disable low voltage programming
        
    DEFINE OSC 10
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 71 ' 9600 Bauds @11.0592 MHZ
    DEFINE HSER_CLOERR 1
    
    PAUSE 500 ' kind of start-up delay... could be remove or reduced
    Start:
          Hserout ["Serial comm test @9600 bauds",13,10]
          pause 500
          goto start
    For the available crystal speed... it's hidden in the PBP manual in appendix with all the available DEFINE at the end of the manual AND/OR in the Help file of MicroCode Studio.

    And the last thing, just be sure you program with the right PIC model 16F877 is not the same as 16F877A. But as another program work... that couldn't be a problem.
    Steve

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

  5. #5
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Default Reply to Steve, serial output success.

    Hi Steve,
    You are a very bright fellow, and much more helpful than a bunch of dubious sample programs and not very clear books. At much more reasonable price too.

    Suppose I'm spoiled by how long the 8031 based parts and tools have had to refine their efforts. But it shouldn't be that hard to write an example of using a command, a list of what the allowable varibles are, and what each effects.

    To paraphrase, there are a lot of learning opportunities here.

    Best Regards,
    Bobby

  6. #6
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Default Not to overlook.

    I still stand by the comment that 8 variations of:

    Error c:\pbp\pbppic14.lib 2827 : [225] Undefined Symbol 'PAUSEUS'

    Is just a goofy error msg for having selected an illegal clock speed.

    Bobby

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


    Did you find this post helpful? Yes | No

    Default

    I can agree. It should be something like illegal crystal speed definition but, once you know the problem source... it will never happen again. Well i guess.
    Steve

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

  8. #8
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Talking Small wager

    Quote Originally Posted by mister_e
    I can agree. It should be something like illegal crystal speed definition but, once you know the problem source... it will never happen again. Well i guess.
    Hi Steve,

    I'd be willing to make a small wager, perhaps a drink, that if another assembler were selected the same mistake would produce a different error.
    Call me a cynic but I'll go double or nothing that it's equally obsure...

    BR,
    Bobby

  9. #9
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobbyA
    Hi,
    >DEFINE OSC 11 is an illegal setting.

    Where does any documentation say that ?

    I probably would have noticed if somewhere it said:
    THE ONLY ACCEPTABLE CLOCK SPEEDS ARE, 3(3.58) 4 8 10 12 16 20 24 25 32 33 40
    See PBP Manual Appendix B "Defines"

    EDIT:
    ok, Steve was faster (as most of the time)
    Last edited by NavMicroSystems; - 1st August 2005 at 00:02.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  10. #10
    BobbyA's Avatar
    BobbyA Guest


    Did you find this post helpful? Yes | No

    Default Reply to Ralph

    Quote Originally Posted by NavMicroSystems
    See PBP Manual Appendix B "Defines"

    EDIT:
    ok, Steve was faster (as most of the time)
    Hi Ralph,

    Actually I did read quite a bit before coming to the site and forums for help.

    The less comprehensive the books the more room for interpetation.
    Does:

    DEFINE BUTTON_PAUSE 10 mean that only 10 ms is the acceptable period.

    DEFINE HSER_TXSTA 20h mean that 24h is an illegal number.

    DEFINE OSC 4 mean that 3(3.58) 4 8 10 12 16 20 24 25 32 33 40 are the only acceptable numbers.

    All of these are from the appendix you mention.

    Point of this is until you know the tools or the manual tells you, you really won't know if the tool calculates the intervals from the number you enter or looks it up from a table, or something else completely. Or can only handle integers for that matter.
    I do appreciate the help though.

    Best Regards,
    Bobby

  11. #11
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobbyA
    ...The less comprehensive the books the more room for interpetation.
    Does:

    DEFINE BUTTON_PAUSE 10 mean that only 10 ms is the acceptable period.

    DEFINE HSER_TXSTA 20h mean that 24h is an illegal number.

    DEFINE OSC 4 mean that 3(3.58) 4 8 10 12 16 20 24 25 32 33 40 are the only acceptable numbers.

    All of these are from the appendix you mention.
    I agree,
    in some things the Manual is not very clear.

    The OSC Table is mentioned in Section 5.51 as well without clearly telling you these values are the only ones to be used, but it refers to the "Section on Speed".

    and
    Section 7.1 "How fast is fast enough" clearly says:

    The acceptable oscillator definitions are...
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. Q: using MCLR for Input on 12F683
    By picster in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 31st January 2009, 15:25
  5. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06: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