serin/hserin fail when i break the standard...


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    OK its gone from bad to worse.....

    On the downside my internet is down so I only have this mobile phone, but I have now dusted off my old dual trace scope...

    What it Ias shown me is I seem to have a timing error...

    I have changed from a 4 to a 20mhz crystal go case It was off freq.

    I can't use the scope to check timing accuracy its very old and calibrated.

    I can't cut and paste my configs now!

    As a rule of thumb, if I use the right settings to clock the pic at 20mhz I would be right with pll/5 to be right for usb.

    CAn I get a good 9600 set that way?

    How many chars can be transferred in say 10 secs?

    The scope shows returning data but it looks like the phone/modem. IS at a different speed

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This is what you need with a 4MHz external
    Code:
    DEFINE OSC 48
    @ __CONFIG   _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG   _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H 
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    thanks, i'll try that in the morning and report back, my net connections up at the moment! if its still up ion the morning i'll post pics off the scope etc of the data to from the gsm modem/phone.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    This is what you need with a 4MHz external
    Code:
    DEFINE OSC 48
    @ __CONFIG   _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG   _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H 
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L

    Ok been away from this for a few days, sanity protection etc...

    tried that in my 18f2550.inc, all worked except for icprt_off_4l was causing an error, so i will leave that bit out for now.

    Am i right in the assumption if i want to also try with a 20mhz crystal then only thing i need change is the plldiv to a 5, and leaving cpudiv as is will still then give me 48mhz clocking?

    I have acquired a USB/rs232 dongle from the usual chinese supplys on ebay, I thought it would be pl2303 based inside but its a full 3 chipset device, so looks very reliable, made by targus, app not windows 7 compat, but on xp so...

    Anyhow, by plugging this in the folowing manner

    usb<----targus232-----<---max232----sniffer wire and spare tx wire

    by doing the above and setting xp's device mangler to 9600, i can see on my scope signals fro the targus are very like what i get from the 18f2550, by connecting the 'sniffer wire' to the 18f2550, i can see data from the pic, if i incorrectly set the targus, i dont, so the fail proves that its not autobauding and that when it receives char's at a displayed 9600, it really is 9600

    so, looks like the pic is tx'ing correctly, and i with the sniffer wire i can see when i connect the 'gsm unit' to the pic, and tell it to 'atdt123' that it replies with 'atdt123' (echo must be on) then after a pause it sends 'no carrier'

    I can not seem to receive the 'no carrier' with the pic, but the sniffer wire proves its being sent back, and at the same data rate, ie 9600

    so as i have no hadshaking, either i am misisng the window of opportunity, which i doubt as i have about 3 seconds to prep for it, or the 3v logic is too low to trigger hserin

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Ok I have a small amount of progress...


    I have managed to receive a single char!

    I did this by connecting the pic to the max232 to the 232/usb dongle and using a comms app....

    I got the pic to wait for the char and output its binary value on portb, sure enough, 65 for an A

    Problem.....

    if i send 'A' then it works, if I send AA or AAA it works, but if I send AAAA ith receives the A and display 65, then goes deaf on me and recieves nothing after that.

    buffer overflow and then stalled?

    program still running, but it goes deaf as a post, 4 chars and deafness.

    It even seems to receive from the 3v gsm unit but says char received is 0, when it should be 'N', and then it goes deaf, no doubt as 'no carrier' is more than 4 chars as above.

    surely theres a simple way to resolve this ?

    I have set the buffer flag to clear over runs etc, and I read I have a 2 byte buffer, so do 2 hserins before i start the loop each time to clear it, I thought that would be enough....

    if i can stop it choking, then i can just leave it running in a loop echoing back allowing me to investigate the probably 3v/5 issue, although using the max232 i dont have that issue at the moment

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try adding this after the HSERIN
    Code:
    RCSTA.4 = 0 : RCSTA.4 = 1
    Dave
    Always wear safety glasses while programming.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    actually i think i have found an answer, may not be right one, gonna do some testing, but will try that too.

    one thing i can say, it works with 3v serial, infact i'm at about 2.8v, and its stable.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 225 ' 9600 Baud @ 48MHz, 0,0%
    SPBRGH = 4
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

    the above lines cured all my serial in problems.

    I think the last 3 were the important bits, but now when the buffer fills it just ignores extra chars etc, no more ''going deaf''

    using them with

    Code:
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    And a 20mhz crystal gives trouble free operation to the phone/module, and no issue with the 3v signals.

    I had to remove the resistor/led combination from the rx pin, it was loading the module a little and dropping its voltage down too low to be seen by the pic, but with a direct connection transfers have been error free. (measured on voltmeter as 2.8v, 2.75 and bits go missing...)


    Thanks to everyone for there input and ideas, I dont know where I would have been without you all this last few weeks!

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

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