Still HSEROUT woes


Closed Thread
Results 1 to 35 of 35

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    In the PBP program. HSERIN clears the flag.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    yeah right but how about if you move the main HSERIN to the interrupt routine?
    Steve

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

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    What happens if you remove the line?:

    DEFINE NO_CLRWDT 1

    When I plugged you code into MPLAB and ran the sim, it gave me a watchdog timeout.

    Steve

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


    Did you find this post helpful? Yes | No

    Default

    but if the watchdog timer is not set in the config fuse, it won't change anything... at least i guess.
    Steve

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

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    mister_e,

    You insight is very helpful! Interrupts were, indeed killing the HSEROUT routine. Setting INTCON to "0" just before the HSEROUT allows the characters to be output properly.

    Grabbing the character with HSERIN inside the ISR works as well!

    This helps a lot, but I don't believe that I can disable ints during serial transmission. MAYBE I can work around this.

    It would be nice to know if I have a bug in my ISR, or if PBP itself has a bug that prevents HSEROUT from being an interruptable routine.

    By the way. Everyone else seems to have found a nice way to include formatted code without putting it "in line". Could you please tell me how to do that?
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    Great!!!

    look the following link for VB code
    http://www.picbasic.co.uk/forum/misc.php?do=bbcode
    Steve

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

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Just to answer the random notes around the thread and also to summarize:

    The watchdog timer was disabled during programming.
    The interrupt worked exactly as expected (that is, it DID provide a 'tick' every
    millisecond).

    Writing the interrupt in pure assembly, saving Wreg,STATUS, FSR0L, and FSR0H
    produced EXACTLY the same result as using a modified "Tim Box" routine which saves the same registers as above PLUS all the PBP registers.

    Does this prove that HSEROUT cannot be interrupted? I have a question in to MELabs.
    Charles Linquist

  8. #8
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Interrupts no problem with HSEROUT Here.

    Charles and Steve,
    I took Charles code and made a couple of slight changes (in italics) to accomadate a different PIC (PIC18F4620) and to send out a longer string of serial data. It ran just as expected.

    Here is the code I ran:
    Code:
    DEFINE  OSC 40 'Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40 
    ;define LOADER_USED 1
    @        __CONFIG    _CONFIG1H, _OSC_HSPLL_1H
    @        __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
    @        __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
    @        __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    
    ;DEFINE NO_CLRWDT 1
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 20H
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE LOADER_USED 1 ' Bootloader
    Define USE_LFSR 1
    
    T0CON = %10001000
    INTCON = %11100000 ' Timer0 and Peripheral interrupts enabled
    PIE1 = %00100000 ' USART 1 receive buffer int enable
    
    '************************************************* ***************************************
    '* *
    '* Declare variables *
    '* *
    '************************************************* ***************************************
    
    
    W_HP_Save         var byte    BANKA  ' Save location for W in BANKA
    STATUS_HP_Save    var byte    BANKA  ' Save location for STATUS register in BANKA
    BSR_HP_Save       var byte    BANKA  ' Save location for BSR register in BANKA
    
    R0_2 var WORD BANKA ' PBP VARS TO SAVE
    R1_2 VAR WORD BANKA
    R2_2 VAR WORD BANKA
    R3_2 VAR WORD BANKA
    R4_2 VAR WORD BANKA
    R5_2 VAR WORD BANKA
    R6_2 VAR WORD BANKA
    R7_2 VAR WORD BANKA
    R8_2 VAR WORD BANKA
    FLAGS_2 VAR BYTE BANKA
    GOP_2 VAR BYTE BANKA
    RM1_2 VAR BYTE BANKA
    RM2_2 VAR BYTE BANKA
    RR1_2 VAR BYTE BANKA
    RR2_2 VAR BYTE BANKA
    
    TIMER VAR WORd
    X VAR WORD 
    Y VAR BYTE
    
    SecondsCounter VAR BYTE
    TimerFlag VAR BIT
    KeyHitFlag VAR BIT
    
    DEFINE INTHAND INT_CODE 'Tell PBP Where your code starts on an interrupt
    
    T0CON = %10001000
    INTCON = %11100000 ' Timer0 and Peripheral interrupts enabled
    PIE1 = %00100000 ' Usart1 int enabled
    
    
    TimerFlag = 0
    Timer = 0
    X = 0
    SecondsCounter = 0
    KeyHitFlag = 0
    
    GOTO OVER_INT_CODE
    
    asm
    	
    INT_CODE
        movwf   _W_HP_Save                 ; 1 copy W to W_HP_Save register
        movff   STATUS, _STATUS_HP_Save    ; 2 copy status reg to STATUS_HP_Save
        movff   BSR, _BSR_HP_Save          ; 3 copy BSR to BSR_HP_Save
    	
    	MOVFF R0,_R0_2
    	MOVFF R0+1,_R0_2+1
    	MOVFF R1,_R1_2
    	MOVFF R1+1,_R1_2+1
    	MOVFF R2,_R2_2
    	MOVFF R2+1,_R2_2+1
    	MOVFF R3,_R3_2
    	MOVFF R3+1,_R3_2+1
    	MOVFF R4,_R4_2
    	MOVFF R4+1,_R4_2+1
    	MOVFF R5,_R5_2
    	MOVFF R5+1,_R5_2+1
    	MOVFF R6,_R6_2
    	MOVFF R6+1,_R6_2+1
    	MOVFF R7,_R7_2
    	MOVFF R7+1,_R7_2+1
    	MOVFF R8,_R8_2
    	MOVFF R8+1,_R8_2+1
    	
    	
    	IFDEF T2
    	MOVFF T2,_T2_2 
    	ENDIF
    	IFDEF FLAGS
    	MOVFF FLAGS,_FLAGS_2 
    	ENDIF
    	IFDEF GOP
    	MOVFF GOP,_GOP_2
    	ENDIF
    	IFDEF RM1
    	MOVFF RM1,_RM1_2
    	ENDIF
    	IFDEF RM2
    	MOVFF RM2,_RM2_2 
    	ENDIF
    	IFDEF RR1
    	MOVFF RR1,_RR1_2 
    	ENDIF
    	IFDEF RR2
    	MOVFF RR2,_RR2_2
    	ENDIF
    
    
    endasm
    ;%%%%%%%%%%%%%%%%%%%%%%%%% Interrupt handler written in PBP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    IF INTCON.2 = 1 THEN
    TMR0H = $EC ; Reload TMR0 to 65535 - 5000
    TMR0L = $77
    Timer = Timer + 1
    IF Timer >= 1000 THEN
    TimerFlag = 1
    ENDIF 
    
    ENDIF
    
    IF PIR1.5 = 1 THEN
    KeyHitFlag = 1
    ENDIF 
    INTCON.2 = 0 ; Clear the timer flag
    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%``
    
    ASM
    	
    	MOVFF _R0_2,R0
    	MOVFF _R0_2 + 1,R0 + 1
    	MOVFF _R1_2,R1
    	MOVFF _R1_2 + 1,R1 + 1
    	MOVFF _R2_2,R2
    	MOVFF _R2_2 + 1,R2 + 1
    	MOVFF _R3_2,R3
    	MOVFF _R3_2 + 1,R3 + 1
    	MOVFF _R4_2,R4
    	MOVFF _R4_2 + 1,R4 + 1
    	MOVFF _R5_2,R5
    	MOVFF _R5_2 + 1,R5 + 1
    	MOVFF _R6_2,R6
    	MOVFF _R6_2 + 1,R6 + 1
    	MOVFF _R7_2,R7
    	MOVFF _R7_2 + 1,R7 + 1
    	MOVFF _R8_2,R8
    	MOVFF _R8_2 + 1,R8 + 1
    
    	IFDEF FLAGS
    	MOVFF _FLAGS_2,FLAGS 
    	ENDIF
    	IFDEF FLAGS
    	MOVFF _GOP_2,FLAGS 
    	ENDIF
    	IFDEF RM1
    	MOVFF _RM1_2,RM1 
    	ENDIF
    	IFDEF RM2 
    	MOVFF _RM2_2,RM2 
    	ENDIF
    	IFDEF RR1
    	MOVFF _RR1_2,RR1 
    	ENDIF
    	IFDEF RR2
    	MOVFF _RR2_2,RR2 
    	ENDIF
    	
    	IFDEF T2
    	MOVFF _T2_2,T2
    	ENDIF 
    	
    	
        movff   _BSR_HP_Save, BSR          ; Restore the BSR reg
        movf    _W_HP_Save, W              ; Restore W
        movff   _STATUS_HP_Save, STATUS    ; Restore the STATUS reg
        Retfie                             ; Exit the interrupt routine
    
    ENDASM
    
    OVER_INT_CODE:
    
    Topp:
    IF TimerFlag = 1 THEN
    SecondsCounter = SecondsCounter + 1
    HSEROUT ["Seconds = ",#SecondsCounter,13,10]
    HSEROUT ["abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWZYZ1234567890",_
    		rep "1"\10,rep "2"\10,rep "3"\10,rep "4"\10,rep "5"\10,13,10]
    TimerFlag = 0
    Timer = 0
    ENDIF
    IF KeyHitFlag = 1 THEN
    HSERIN [Y]
    HSEROUT[Y]
    KeyHitFlag = 0
    ENDIF 
    INTCON.7 = 1 ; Turn global Ints back on 
    Goto Topp
    Here is the output:
    Name:  untitled.jpg
Views: 1075
Size:  177.7 KB

    So...
    I don't think it's a problem with the HSEROUT being interrupted.

    Steve

Similar Threads

  1. I2C Slave with a PIC
    By ralfmayr in forum mel PIC BASIC Pro
    Replies: 129
    Last Post: - 21st August 2016, 18:44
  2. hserin and sms controller
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 10th February 2010, 16:49
  3. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 20:12
  4. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 17:26
  5. Controlling an 240x128 LCD Touchpanel Display
    By Vincent in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th June 2006, 00:36

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