PIC16F1947 trouble


Today 18:19
Forum: Proton Plus Compiler v3
Starter: Les
Views: 0
Replies: 16
Today 15:54
Forum: GPS
Starter: SimonJA
Views: 0
Replies: 14
Go to last post By: tumbleweed
Today 14:37
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 1
Go to last post By: fanie
Today 14:10
Forum: The Lounge
Starter: John Drew
Views: 0
Replies: 12
Today 12:55
Forum: The Lounge
Starter: fanie
Views: 0
Replies: 18
Today 02:12
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 5
Today 01:13
Forum: The Lounge
Starter: Tim
Views: 0
Replies: 25
Yesterday 19:17
Forum: The Lounge
Starter: basparky
Views: 0
Replies: 14
+ Reply to Thread
Results 1 to 5 of 5

Thread: PIC16F1947 trouble8 days old

  1. #1
    Member CharlieBrown's Avatar
    Join Date
    Jul 2006
    Posts
    147
    Thumbs Up
    Received: 1
    Given: 13
    Total Downloaded
    3.09 GB

    0 Not allowed!

    Default PIC16F1947 trouble

    I am having some problem with a very simple LCD routine to run on 16F1947.

    My code is -
    Code:
        Device = 16F1947
    
    
        Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_ON, CP_OFF, CPD_OFF, BOREN_OFF, CLKOUTEN_OFF, IESO_ON, FCMEN_ON
        Config2 WRT_OFF, VCAPEN_OFF, PLLEN_OFF, STVREN_ON, LVP_OFF
    
    
        OSCCON = %01111010              '16 MHz HF
        Xtal 16                         ' OSC Speed for compiler. Xtal 16 for 32Mhz
        Declare All_Digital = TRUE
        Declare PORTB_Pullups = OFF
        
        ADCON0 = %00000000             ' %xxxxxxx1 A/D ON bit NO ADC
        ANSELA = %00000000
        ANSELF = %00000000
        ANSELG = %00000000
        
        OPTION_REG.7 = 1                ' 0-Enables Weak Pull-ups
    
    
               ; 76543210    
        TRISA = %11110000
        TRISB = %11111111    
        TRISC = %01011010               ' RX PIN SHOULD ALWAYS BE INPUT
        TRISD = %11111110
        TRISE = %00000000
        TRISF = %10100000
        TRISG = %11010000
       
        Declare LCD_Type 0                  ' Type of LCD Used is Alpha
        Declare LCD_Lines 2
        Declare LCD_DTPin PORTA.0           ' The control bits 
        Declare LCD_RSPin PORTF.1           ' RS pin on F1
        Declare LCD_ENPin PORTF.0           ' E pin on F0
        Declare LCD_Interface 4             ' Interface method is 4 bit
        
       MAIN:
       
       Clear
       
       Cls
       Print At 1,1,"HARDWARE TESTING"
       Print At 2,1,"LCD display"
    
    
       DelayMS 2000
       
    End
    I am just not getting any output on the LCD.

    Seems this is a funny microchip chip.

    Any help ?

    charlie

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Member teo's Avatar
    Join Date
    Sep 2010
    Posts
    276
    Thumbs Up
    Received: 11
    Given: 1
    Total Downloaded
    3.87 GB

    1 Not allowed!

    Default Re: PIC16F1947 trouble

    From Manual:
    Declare LCD_DTPin Port . Pin
    Assigns the Port and Pins that the LCD's DT lines will attach to.
    The LCD may be connected to the microcontroller using either a 4-bit bus or an 8-bit bus. If an
    8-bit bus is used, all 8 bits must be on one port. If a 4-bit bus is used, it must be connected to
    either the bottom 4 or top 4 bits of one port. For example: -
    Declare LCD_DTPin PORTB.4 ' Used for 4-line interface.
    Declare LCD_DTPin PORTB.0 ' Used for 8-line interface.
    In the above examples, PORTB is only a personal preference. The LCD's DT lines can be attached
    to any valid port on the microcontroller. If the Declare is not used in the program, then
    the default Port and Pin is PORTB.4, which assumes a 4-line interface.
    Declare LCD_DataX_Pin Port . Pin
    Assigns the individual Ports and Pins that the HD4470 LCD’s DT lines will attach to.
    Unlike the above LCD_DTPin declares, the LCD’s data pins can also be attached to any seperate
    port and pin. For example:-
    Declare LCD_Data0_Pin PORTA.0 ' Connect PORTA.0 to the LCD’s D0 line
    Declare LCD_Data1_Pin PORTA.2 ' Connect PORTA.2 to the LCD’s D1 line
    Declare LCD_Data2_Pin PORTA.4 ' Connect PORTA.4 to the LCD’s D2 line
    Declare LCD_Data3_Pin PORTB.0 ' Connect PORTB.0 to the LCD’s D3 line
    Declare LCD_Data4_Pin PORTB.1 ' Connect PORTB.1 to the LCD’s D4 line
    Declare LCD_Data5_Pin PORTB.5 ' Connect PORTB.5 to the LCD’s D5 line
    Declare LCD_Data6_Pin PORTC.0 ' Connect PORTC.0 to the LCD’s D6 line
    Declare LCD_Data7_Pin PORTC.1 ' Connect PORTC.1 to the LCD’s D7 line
    There are no default settings for these Declares and they must be used within the BASIC program
    if required.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,068
    Thumbs Up
    Received: 336
    Given: 126
    Total Downloaded
    1.52 GB

    1 Not allowed!

    Default Re: PIC16F1947 trouble

    Unfortunately Charlie, you've found another quirk in the microchip architecture that I hadn't coded for. :-(

    Usually, all PORT SFRs are in the same RAM bank and all TRIS SFRS are in the same RAM bank, however, Microchip have overstretched the enhanced 14-bit core device and it appears there wasn't enough room in RAM bank 0 for PORTF and PORTG, where ports A, B, C, D and E are, so they have moved these 2 PORT SFRs into a different RAM bank, the same with TRISF and TRISG in. The compiler's LCD code does not take this quirk into account so it does not set the RAM banks for the separate PORT accesses it has to do to toggle pins etc... I made the assumption that all the PORT and TRIS SFRs would be in the the same RAM banks as each other, which is the case for all other devices, but not on this one. :-)

    I'm busy making the changes to the code for these types of devices, but it will take a day or so. Unfortunately, it will also make the code larger because there now needs to be separate Movlb mnemonics whenever pins are accessed, so the RAM bank is changed all the time. How stupid is that for a design of hardware?

    The immediate fix is to make the EN and RS pins attach to any port except PORTF or PORTG, the same with the LCD's data pins, but PORTA is fine.

    Sorry about that Charlie, but Microchip keep changing things that have been standard in the devices for a decade or so, and do not make a point of indicating this in the datasheets! IMO, one of the first sections of a datasheet should be "differences to the standard architecture", if there are any.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Member CharlieBrown's Avatar
    Join Date
    Jul 2006
    Posts
    147
    Thumbs Up
    Received: 1
    Given: 13
    Total Downloaded
    3.09 GB

    0 Not allowed!

    Default Re: PIC16F1947 trouble

    thanks LES for the help and consideration. Unfortunately the PCBs have been made and the port pins were selected for ease of layout and proximity. I shall wait for your help and support on this one.

    Also I observed some EEPROM Read/Write issues, like EDATA labels would not work. Could you also look into that too.

    Thank you.
    Charlie

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,068
    Thumbs Up
    Received: 336
    Given: 126
    Total Downloaded
    1.52 GB

    0 Not allowed!

    Default Re: PIC16F1947 trouble

    I've tested on-board eeprom read and write with the 16F1947, and they are working fine:

    I used the simple program below to read and write the on-board eeprom, and all values are correct:
    Code:
        Device = 16F1947
        Declare Xtal = 32
       
        Declare Hserial1_Baud = 9600 
       
    EE_Start_8  EData  10 ,  11 ,  12 
    EE_Start_16 EData  1000 ,  10000 
    EE_Start_32 EData  100000 ,  1000000 
       
        Dim bEE_Address As Byte
        Dim bEE_Data As Byte
        Dim wEE_Data As Word
        Dim dEE_Data As Dword 
    
    Main:   
        HRSOutLn "Default Values"
        Read_Eeprom()                       ' Read the default values from the on-board eeprom
        
        HRSOutLn "Writing values to Eeprom"     
        EWrite EE_Start_8,[100, 101, 102]
        EWrite EE_Start_16,[2000, 20000]
        EWrite EE_Start_32,[200000, 2000000]
    '
    ' Read the values written to the eeprom
    '    
        HRSOutLn  "New Values" 
        Read_Eeprom()                       ' Read the new values from the on-board eeprom
        Stop
    '
    ' Read data from the on-board eeprom
    ' 
    Sub Read_Eeprom()   
        HRSOutLn "Read 8-bit values"
        For bEE_Address = EE_Start_8 To EE_Start_8 + 2
            bEE_Data = ERead bEE_Address
            HRSOutLn Dec bEE_Data
        Next
        
        HRSOutLn "Read 16-bit values"
        For bEE_Address = EE_Start_16 To EE_Start_16 + 3 Step  2 
            wEE_Data = ERead bEE_Address       
            HRSOutLn Dec wEE_Data
        Next
        
        HRSOutLn  "Read 32-bit values" 
        For bEE_Address = EE_Start_32 To EE_Start_32 + 7 Step  4 
            dEE_Data = ERead bEE_Address       
            HRSOutLn Dec dEE_Data
        Next 
    EndSub
    On the serial terminal I receive:

    Default Values
    Read 8-bit values
    10
    11
    12
    Read 16-bit values
    1000
    10000
    Read 32-bit values
    100000
    1000000
    Writing values to Eeprom
    New Values
    Read 8-bit values
    100
    101
    102
    Read 16-bit values
    2000
    20000
    Read 32-bit values
    200000
    2000000
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Trouble with .inc files
    By Rlake in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 14th September 2014, 23:44
  2. GLCD trouble
    By chuckieboy in forum The Lounge
    Replies: 4
    Last Post: 13th February 2012, 23:02
  3. Trouble with arrays
    By RGV250 in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 11th July 2007, 08:48
  4. If then trouble.............
    By joesaliba in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 25th April 2007, 12:28
  5. Still having trouble posting!
    By C_Moore in forum Website / Forum Issues
    Replies: 2
    Last Post: 6th April 2006, 12:20

Members who have read this thread since 21st January 2019, 10:11 : 1

Actions :  (Set Date)  (Clear Date)

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