On Saturday 07 October 2006 16:13, Scott Dattalo wrote:

>
> I'm really pleased to see that you're using gpsim for your development!
>

Not as pleased as I am to have such a useful tool available.  I rather like 
the breadboard facility, allows you to see what is happening in real (or 
realish) time if you have a lot of long loops.


> The reason gpsim halted is because address 0x90 is invalid for the
> 16F877. The T1CON register (which I assume you're attempting to address)
> is at address 0x10. So the problem is that your bank register is
> incorrect; your pointing into bank 01 when you should be pointing into
> bank 00. I don't know if the offending code was written by you or SDCC,
> but in either case you may track down where the bank was (or was not)
> getting written by using gpsim's trace command. For example, you can say
> 'trace 100' to see what has happened for the last 100 instruction
> cycles. This will allow you to inspect where things went awry.

The offending assembly code was written by by sdcc from my C, the routine 
stops in a software serial port driver bit of code, from looking at the 
source browser (I know most pics nowadays have USARTS but I thought it 
would be better to have a software solution working first).

However, this code has been fine earlier, it has been working on my 
pic16f877 development board for over a week when used with other routines.  
My assumption is that the use of more variables in other bits of code has 
caused sdcc to move one of the variables used by the serial routine into a 
place it should not have.

Note I've been a bit lazy with my delay routine, basically estimating the 
delays by viewing the resultant RS232 signals on a scope.  I should have 
produced the delay using in-line assembly so I knew exactly what the 
delays were!  I've left all the comments just in-case I've made a boo-boo 
there!

C: 

void Half_Bit_Delay(void) {
        
        unsigned char loop;

        //OK, PIC clocking at 20MHz
        // /4 = 5MHz
        // 200nsec per instruction
        // If we go for 19200 baud
        //52 instruction pause
        //assume loop takes 2, 26, but half bit, 13 
        // assume 4 instruction overhead
        //9

        //Go for 9600 baud delay of 128

        //With 128 1.5msec for 10 bits worth, start 8 stop
        //That gives a baud rate of 1.5 e -03 / 10 equates
        //to 6667 baud
        //Correct ! 128 *  6667 / 9600 = 89!
        //Which gives 8333 baud!
        
        //Tweek slihtly faster

        

        for (loop = 0; loop < 79 ; loop++ ) {
        }

}

Assembly produced by sdcc, gpsim freezes where marked:

;***
;  pBlock Stats: dbName = C
;***
;entry:  _Half_Bit_Delay        ;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
;   r0xB0
;; Starting pCode block
_Half_Bit_Delay ;Function start
; 2 exit points
;       .line   103; "../plibpic/serial/serial-sw-2006-10-5.h"  for (loop = 0; 
loop 
< 79 ; loop++ ) {
        MOVLW   0x4f
        BANKSEL r0xB0
        MOVWF   r0xB0
_00115_DS_
        DECFSZ  r0xB0,F
        GOTO    _00115_DS_      <----- GPSIM seems to stop here!
        RETURN  
; exit point of _Half_Bit_Delay

All a bit odd though, as the routine works for a while before it bangs out.  
Also, I though sdcc insulated me from setting bank bits?  Also a bit 
perplexed.

Hmm, a lot of code playing around at 0x90 from elsewhere in my serial 
routine, a code snippet.  Looks like it would be valid if the pic is 
working in banks 2 or 3 but from the error message I would assume it is in 
bank 0?  I'm a bit confused by the 'BANKSEL' instruction, I assume it is 
some sort of assembler macro rather than a PIC instruction.



;       .line   257; "../plibpic/serial/serial-sw-2006-10-5.h"  
serialbuff[serialbuff_index] = in;
        BANKSEL _serialbuff_index
        MOVF    _serialbuff_index,W
        ADDLW   (_serialbuff + 0)
        MOVWF   r0x90
        MOVLW   high (_serialbuff + 0)
        BTFSC   STATUS,0
        ADDLW   0x01
        MOVWF   r0x91
        MOVF    r0x90,W
        MOVWF   FSR
        BCF     STATUS,7
        BTFSC   r0x91,0
        BSF     STATUS,7
        MOVF    r0x8F,W
        MOVWF   INDF


I need to RTFM a bit on trace, I seem either to get the last instruction or 
a lot of short lines of hex!

Pete

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to