Simple code but strange result - 877A


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1

    Default Simple code but strange result - 877A

    Hello, I have written the following code but for some reason it is not working:
    Code:
    Include "modedefs.bas"
    DEFINE OSC 4
    @ __Config _XT_OSC & _WRT_256 &_WDT_OFF &_PWRTE_ON &_BODEN_OFF & _LVP_OFF
    
    PAUSE 10
    '-----------------------------------------------------
    DEFINE DEBUG_REG PORTC
    DEFINE DEBUG_BIT 6
    DEFINE DEBUG_BAUD 4800
    DEFINE DEBUG_MODE 0
    
    DEFINE DEBUGIN_REG PORTC
    DEFINE DEBUGIN_BIT 7
    DEFINE DEBUGIN_MODE 0
    @ ERRORLEVEL -306
    
    '------------------------------------------------------
    ADCON1=7
    CMCON=7
    INTCON=128
    OPTION_REG.7=0
    TRISA=0 : PORTA=0
    TRISB=0 : PORTB=0
    TRISC=%10000000 : PORTC=0
    TRISD=0 : PORTD=0
    TRISE=0 : PORTE=0
    CCP1CON=0
    '-----------------------------------------------------
    main:
    TOGGLE PORTA.0
    		DEBUG "AT",13,10
    		DEBUGIN 500,main,[WAIT("OK")]
    PAUSE 500
    goto main
    When I comment DEBUGIN, PortA.0 starts toggling. Else, my LED at PortA.0 just stays ON on power up.
    Can someone point out my mistake if any please?
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Simple code but strange result - 877A

    financecatalyst , You told it to "WAIT" for an OK to be sent before it is to resume..

    DEBUGIN 500,main,[WAIT("OK")]

    Dave Purola,
    N8NTA

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Simple code but strange result - 877A

    I have changed the code to use USART, things have progressed, LED at PortA.0 toggles every second, BUT there is constant voltage on the TX PIN. Rx works fine as it is connected to my computer via MAX232. So whenever I send an OK from my computer the toggling of the led is delayed for 3 seconds appx.

    I do not see "AT" on my terminal window

    Code:
    PAUSE 10
    '-----------------------------------------------------
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    @ ERRORLEVEL -306
    
    '------------------------------------------------------
    ADCON1=7
    CMCON=7
    INTCON=128
    OPTION_REG.7=0
    TRISA=0 : PORTA=0
    TRISB=0 : PORTB=0
    TRISC=%10000000 : PORTC=0
    TRISD=0 : PORTD=0
    TRISE=0 : PORTE=0
    CCP1CON=0
    '-----------------------------------------------------
    main:
    TOGGLE PORTA.0
    		HSEROUT  ["AT",13,10]
    		HSERIN 1000,main,[WAIT("OK")]
    PAUSE 2000
    goto main
    ___________________
    WHY things get boring when they work just fine?

  4. #4


    Did you find this post helpful? Yes | No

    Default 877A with Modem. Communication Problem

    I have written a small code to send AT commands to the Modem and then get an OK back. I have put my computer's RS232 connections in Parallel to keep an eye on the communication.

    But My PIC is not Transmitting anything - I need help to make this work

    My code is as follows:
    Code:
    Include "modedefs.bas"
    DEFINE OSC 4
    @ __Config _XT_OSC & _WRT_256 &_WDT_OFF &_PWRTE_ON &_BODEN_OFF & _LVP_OFF
    
    PAUSE 10
    '-----------------------------------------------------
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    @ ERRORLEVEL -306
    
    '------------------------------------------------------
    ADCON1=7
    CMCON=7
    INTCON=128
    OPTION_REG.7=0
    TRISA=0 : PORTA=0
    TRISB=0 : PORTB=0
    TRISC=%10000000 : PORTC=0
    TRISD=0 : PORTD=0
    TRISE=0 : PORTE=0
    CCP1CON=0
    '-----------------------------------------------------
    main:
    TOGGLE PORTA.0
    		HSEROUT  ["AT",10,13]
    		HSERIN 1000,main,[WAIT("OK")]
    PAUSE 2000
    goto main
    The receiving end is working fine, as I can send the "OK" from my terminal window and my PIC is getting it. But nothing appears on my Terminal window from the PIC.

    I have checked that there is a constant voltage on the TX pin, 4.6V. Is something wrong with my code?
    ___________________
    WHY things get boring when they work just fine?

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Simple code but strange result - 877A

    Do you have a schematic? What's RC.6 connected to?

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Simple code but strange result - 877A

    Quote Originally Posted by scalerobotics View Post
    Do you have a schematic? What's RC.6 connected to?
    rc.6 ->Pin11 (MAX232) -> Pin14(MAX232) -> Modem Pin3 (Female RS232)
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default Re: Simple code but strange result - 877A

    Hi,
    I have NEVER used the USART to transmit so if I am wrong, . . . well here is my try . . .
    TXSTA.5 = 1 'which is transmit enable bit.
    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.

  8. #8


    Did you find this post helpful? Yes | No

    Unhappy Re: Simple code but strange result - 877A

    Quote Originally Posted by Joe S. View Post
    Hi,
    I have NEVER used the USART to transmit so if I am wrong, . . . well here is my try . . .
    TXSTA.5 = 1 'which is transmit enable bit.
    Didn't Work
    ___________________
    WHY things get boring when they work just fine?

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