Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Albert

  • Rank
  1. Hi, I found that the index of a far array is only calculated with an 8-bit addition without considering the overflow. You will find a code example and the resulting assembler file in the attachment. I think this is an error, at least in the documentation this is not mentioned. Best regards, PS attaching a .asm or .casm don't work, so you will find it below: #include "PIC16F1847.h" unsigned char uc_arr[192] @0x2270; void main(void) { unsigned char cnt; for(cnt = 0; cnt < 192; cnt++) { 0004 0020 MOVLB 0x00 0005 01A0 CLRF main_1_cnt 0006 label1 0006 30C0 MOVLW 0xC0 0007 0220 SUBWF main_1_cnt, W 0008 1803 BTFSC STATUS,C 0012 0AA0 INCF main_1_cnt, F 0013 2806 GOTO label1 uc_arr[cnt] = cnt; 000A 3022 MOVLW HIGH(gbl_uc_arr) 000B 0085 MOVWF FSR0H 000C 3070 MOVLW LOW(gbl_uc_arr+D'0') 000D 0084 MOVWF FSR0L 000E 0820 MOVF main_1_cnt, W 000F 0784 ADDWF FSR0L, F 0010 0820 MOVF main_1_cnt, W 0011 0080 MOVWF INDF0 } } 0009 0008 RETURN //////////////////////////////////////// // Code with no source :-) //////////////////////////////////////// 0000 2814 GOTO _startup 0014 _startup 0014 3180 MOVLP 0x00 0015 2804 GOTO main TestFarArray.c
  2. I use a PIC16F1847 and the BoostC compiler. I wrote some code which uses 14 bytes of data. Now I have to do the same code but for another data record. I started by writing the same function twice, one for the first data record and the other for the second data record. Because I only have 14 bytes of data but much more code I thought it is better using a pointer, then it is much easier to expand it later too. So I thought, no problem, just put it in two arrays or structures and pass a pointer. But there is a problem, now the code size is blown up in a way that the memory of the pic is too small, before I used about 30% for this and now 60%. So the code size is nearly doubled by using pointers instead of writing the same code twice. With my other code now I am at about 90% but the software is not yet ready. I also tried to use linear addressing, but the code size is nearly the same. Because I only have 2 data records with 14 bytes each, I thought, why not using the banking mechanism of the pic by placing every record at the same address but in another bank. May be that the compiler is intelligent enough to detect this and to generate code which don't use the MOVLB instuction but moves the content of a variable to the BSR register (MOVF BANK,W, MOVWF BSR). All local variables can be doubled too, the data memory size is not the problem. This will not blow up the code size because every function only has to set the BSR once if not using data of another bank. Is there a way to do this? Or is there another possible solution? Best regards, Albert
  3. Nice workaround. But I only have version 7.11 and 7.10 can not be downloaded anywhere. Can you, or anybody else, please provide me with version 7.10? Or is there an update for 7.11 available now? Albert