Serout/Serout2 and PIC18F97J60 (100 pin)


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Question Serout/Serout2 and PIC18F97J60 (100 pin)

    Hi gurus,
    anyone knows WHY this piece of code DOES NOT WORK ???!!!???
    Basically it should send serially the control byte for a MeLabs LCD display
    Instead, I got just junk and instead of receiving 5 character I receice sometimes 2, some other times 3.... But anytime NOT the correct characters.
    I've used all the hardware USART, so I can't use no others and I cannot even modify the board to have a different "multiplexing" solution for the hardware serial port...
    I'm using a resonator at 25Mhz

    Code:
    DEFINE OSC 25                      'Set the Crystal Clock speed
    INCLUDE "modedefs.bas"          'Inline compiler's pre-defined constants
    ADCON0 = 0                          'AD converter module 0 = disabled
    ADCON1 = %00001111            'Set all analog pins to digital
    ADCON2 = %00000000
    CMCON  = %00000111            'Comparator = disabled
    INTCON = %00111000
    INTCON2 = %10000000
    INTCON3 = %00000000
    RCON.7 = %00000000
    EECON2.5 = 0                       'Ethernet Module Disabled
    SSP1CON1.5 = 0                   'Disable SPI 1 and set pins as GPIO
    SSP2CON1.5 = 0                   'Disable SPI 2 and set pins as GPIO
    TRISD.7 = 0                         'PortD7 = RS-232 TX output for Display
    
    LCD            var PORTD.7
    
    Main:
    SEROUT2 LCD, N9600, [$1B, $30, $1B, $2A, $FF] 'Clear the display and set full-on backlight
    pause 1000
    GOTO Main
    My settings for programming the Pic are the following:
    Watchdog timer: Enabled
    Stack Overflow Reset enable: Enabled
    Extended Cpu Enable: Disabled
    Code protect 000000 - 01FFFF: Disabled
    Oscillator: OSC1/OSC2 as primary, HS Osc
    Fail Safe Monitor Clock Enable: Enabled
    Internal External Switch Over Enable: Enabled
    Watchdog Timer Postscale: 1:512
    External Address Bus Shift enable: Enabled
    External Memory Bus Address Mode: Microcontroller mode, External bus disabled
    Data Bus Width Select: 16-bit
    External Bus Wait enabled: Ignore MEMCON.WAIT, Device Will not Wait
    CCP2 Mux: ECCP2 I/O MUXED with RC1
    ECCP Mux: P1B/P1C On RE6/RE5, P3B/P3C On RE4/RE3
    Ethernet Led Enable: LedA/LedB On RA0/RA1 with Ethernet, RA0/AN0 without

    I don't know what else to thing about. Any change to have Serout (and even Serout2 and Serin at work) simply does not work.

    Could be something weird with the Configuration's Bits settings?

    Thank to all in advance.

  2. #2
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Default There is something wrong in PBP

    Ok guys,
    it definitively seems that there is something wrong in the PBP library somewhere.
    The Serout (and Serout2), with PBP2.50A, and the program below, it JUST send 2 or 3 random character (yes, sometimes 2, some other times 3...)

    I've putted a line in the code to flash a led to prove that the loop is going, but putting a scope on the output (on the pin PortD.7), I see only the transmission JUST after the reset and then NOTHING ELSE even if the loop is going and the led is flashing. So the instruction Serout2 bla bla bla, it is simply IGNORED! No transmissions at all, neighter the weird one. Just some character after the power-on.

    The chip is again the PIC18F97J60 (100 pins version).

    Any idea?


    Code:
    DEFINE OSC 25                      'Set the Crystal Clock speed
    INCLUDE "modedefs.bas"          'Inline compiler's pre-defined constants
    ADCON0 = 0                          'AD converter module 0 = disabled
    ADCON1 = %00001111            'Set all analog pins to digital
    ADCON2 = %00000000
    CMCON  = %00000111            'Comparator = disabled
    INTCON = %00111000
    INTCON2 = %10000000
    INTCON3 = %00000000
    RCON.7 = %00000000
    EECON2.5 = 0                       'Ethernet Module Disabled
    SSP1CON1.5 = 0                   'Disable SPI 1 and set pins as GPIO
    SSP2CON1.5 = 0                   'Disable SPI 2 and set pins as GPIO
    TRISJ.7 = 0
    TRISD.7 = 0                         'PortD7 = RS-232 TX output for Display
    
    LCD            var PORTD.7
    LED_what    var PORTJ.7
    
    Main:
    SEROUT2 LCD, N9600, ["Hello World",13,10] 
    pause 1000
    LED_what = ~ LED_what
    GOTO Main
    Thank you.
    Last edited by mikebar; - 18th May 2008 at 13:51. Reason: missing modified code

  3. #3
    Join Date
    Jun 2007
    Posts
    24

    Default N9600

    From one Mike to another,
    I'm not sure on this, but I think that you can only use modedefs.bas and N9600 mode with the SEROUT command not with SEROUT2.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Code:
    SEROUT2 LCD, 84, ["Hello World",13,10]

  5. #5
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Default Still does not work...

    Thank you Skimask and Mikendee.
    I've already tested the code putting 84 instead of N9600, but nothing.
    Actually I modified the program in order to increase a BYTE sized variable "instead" of the 84.
    So, pressig one button, I get that variable increased by 1 (and toggle a led).
    Pressing another button I get that variable decreased by 1 (and toggle the same above led).

    The loop is working because I see the toggling of the LED each time I press some button (debounced as well), but still nothing good...
    Code:
    DEFINE OSC 25                      'Set the Crystal Clock speed
    INCLUDE "modedefs.bas"          'Inline compiler's pre-defined constants
    ADCON0 = 0                          'AD converter module 0 = disabled
    ADCON1 = %00001111            'Set all analog pins to digital
    ADCON2 = %00000000
    CMCON  = %00000111            'Comparator = disabled
    INTCON = %00111000
    INTCON2 = %10000000
    INTCON3 = %00000000
    RCON.7 = %00000000
    EECON2.5 = 0                       'Ethernet Module Disabled
    SSP1CON1.5 = 0                   'Disable SPI 1 and set pins as GPIO
    SSP2CON1.5 = 0                   'Disable SPI 2 and set pins as GPIO
    TRISD.7 = 0                         'PortD7 = RS-232 TX output for Display
    serSpeed        var byte
    
        serspeed = 84
    TestLoop:
        serout2 PortD.7, SERSPEED, ["SerSpeed=", dec serSpeed,13,10]
        if SW_ManualReset = 0 then
            pause 10
            if sw_manualreset = 0 then
                LED_what = ~ LED_what
                serspeed = serspeed - 1
            endif
            while sw_manualreset = 0
            wend
            LED_what = ~ LED_what
        endif
        if SW_PWR_On_Off = 0 then
            pause 10
            if SW_PWR_On_Off = 0 then
                LED_what = ~ LED_what
                serspeed = serspeed + 1
            endif
            while sw_pwr_on_off = 0
            wend
            LED_what = ~ LED_what
        endif
        pause 500
        goto TestLoop
    After the first weird sending then the PortD.7 pin is just muted.
    No other sending even if the loop is still going. Actually if I press one of the buttons, I see that the led is toggling.

    Same result if I change on any pin on PortC.
    Of course, neighter Serin/Serin2 work...

    I submitted the issue to Melabs too.

    Any idea in the meanwhile?

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Time to break it down...
    Does the old blinky LED program blink at the proper rate?
    Code:
    led var portd.7 : output led
    main: led = 1 : pause 500 : led = 0 : pause 500 : goto main
    1 second blinks?

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

    Default

    ..........never mind......................
    Last edited by mister_e; - 19th May 2008 at 16:22.
    Steve

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

  8. #8
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Default Something is working now...

    Thank you Skimask,
    is exactly what I did last night.
    Conclusion:
    The chip is FRIED!
    There is something wrong with the PortD and PortC.
    Actually a new board with another chip it work properly!

    My apologises...

    I've also apologized with MeLabs... even if I submitted another issue to them.
    The new (old) one is related to the fact that the PIR1.5 register seems never find a character in the buffer even if I know that is sure there.
    DEFINE HSER_CLROERR 1 and DEFINE HSER2_CLROERR 1 are both at the top of the program.
    Things start going bad if I use some I2C command and then inquiry the PIR1.5
    What I do not understand is that inquiring PIR3.5 (for the other attached device), it work regularly at any speed (between 2400 and 115200)
    the only way to get data from the device attached is to use HSerin with a timeout of 10ms...
    If I DON'T USE any I2C commands, both PIR1.5 and PIR3.5 reflect the correct data and behaviour...
    I've already posted this strange things in a more detailed post:
    http://www.picbasic.co.uk/forum/showthread.php?t=8638

    Thank you all guys.
    Hope in some hint...
    Last edited by mikebar; - 20th May 2008 at 04:04. Reason: Forgot greetings...

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

    Default

    That's weird... i'll order few sample of this chip just for fun...
    Steve

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

  10. #10
    Join Date
    Aug 2006
    Location
    Italy
    Posts
    72

    Default

    Mister-e,
    thank you very much for your curiosity.
    Be prepared. The package IS EXTREMELY SMALL!

    Let me know if you discover sothing.

    Thank you again.

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

    Default

    No problem, it's an interesting PIC anyways. I'm impressed the 40$ PICKIT 2 support it... while some much more expensive programmer i have don't
    Steve

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

Similar Threads

  1. HSERIN2 not working on PIC18F97J60 ???
    By mikebar in forum Serial
    Replies: 8
    Last Post: - 4th May 2008, 15:20

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