Hello Georg, Unfortunately you cannot attach anything to the mailing list. The system will remove it.
You can however open a support ticket and attach your files there. Maarten > hello Philipp, > > youâre right, with '.eâ outside the brackets it worked right away! Now > I am able to write to and read from the full 128kB STM8 flash :-) > Attached please find the respective routines for SDCC and Cosmic. Passing > arguments between C and assembler is done via global variables g_addr and > g_val. > > Thanks a lot for your support and have a nice Christmas! > Georg > > PS: is there a way to attach .zip files to the mailing list to avoid epic > listings inside the mails? > > ââââââ > > /** > \fn void flash_write_option_byte(uint16_t addr, uint8_t byte) > > \brief write option byte to flash > > \param[in] addr address to write to > \param[in] byte byte to program > > write single option byte to given address > */ > void flash_write_option_byte(uint16_t addr, uint8_t byte) { > > uint8_t *addr_near; // option bytes are in 2B range > > // check address > if ((addr < 0x4800) || (addr > 0x48FF)) > return; > > // disable interrupts > DISABLE_INTERRUPTS; > > // unlock w/e access to EEPROM & option bytes > FLASH_DUKR.byte = 0xAE; > FLASH_DUKR.byte = 0x56; > > // additionally required > FLASH_CR2.byte |= 0x80; > FLASH_NCR2.byte &= 0x7F; > > // wait until access granted > while(!FLASH_IAPSR.reg.DUL); > > // set address > addr_near = (uint8_t*) addr; > > // write option byte to p-flash > *(addr_near++) = byte; > > // wait until done > while (!FLASH_IAPSR.reg.EOP); > > // lock EEPROM again against accidental erase/write > FLASH_IAPSR.reg.DUL = 0; > > // additional lock > FLASH_CR2.byte &= 0x7F; > FLASH_NCR2.byte |= 0x80; > > > // enable interrupts > ENABLE_INTERRUPTS; > > } // flash_write_option_byte > > > > /** > \fn void flash_write_byte(uint32_t addr, uint8_t ch) > > \brief write single byte to flash > > \param[in] addr address to write to > \param[in] ch byte to program > > write single byte to address in P-flash or EEPROM > */ > void flash_write_byte(uint32_t addr, uint8_t ch) { > > // disable interrupts > DISABLE_INTERRUPTS; > > // unlock w/e access to P-flash > FLASH_PUKR.byte = 0x56; > FLASH_PUKR.byte = 0xAE; > > // unlock w/e access to EEPROM > FLASH_DUKR.byte = 0xAE; > FLASH_DUKR.byte = 0x56; > > // wait until access granted > while(!FLASH_IAPSR.reg.PUL); > while(!FLASH_IAPSR.reg.DUL); > > // Cosmic compiler (supports far pointer) > #if defined(__CSMC__) > > // write byte to p-flash (use 3b address for near&far range) > *((@far uint8_t*) addr) = ch; > > // SDCC compiler (doesn't support far pointer --> use inline assembler) > #elif defined(__SDCC) > > // store address & data globally for assember > g_addr = addr; > g_val = ch; > > // use inline assembler > ASM_START > ld a,_g_val > ldf [_g_addr+1].e,a > ASM_END > > #endif // SDCC > > // wait until done > while (!FLASH_IAPSR.reg.EOP); > > // lock P-flash again against accidental erase/write > FLASH_IAPSR.reg.PUL = 0; > > // lock EEPROM again against accidental erase/write > FLASH_IAPSR.reg.DUL = 0; > > // enable interrupts > ENABLE_INTERRUPTS; > > } // flash_write_byte > > > > /** > \fn uint8_t read_byte(uint32_t addr) > > \brief read single byte from memory > > \param[in] addr memory address to read from > > \return byte read from memory > > read single byte from address in memory > */ > uint8_t read_byte(uint32_t addr) { > > // Cosmic compiler (supports far pointer) > #if defined(__CSMC__) > > // return read byte from memory (use 3b address for near&far range) > return(*((@far uint8_t*) addr)); > > // SDCC compiler (doesn't support far pointer --> use inline assembler) > #elif defined(__SDCC) > > // store address & data globally for assember > g_addr = addr; > > // use inline assembler > ASM_START > ldf a,[_g_addr+1].e > ld _g_val,a > ASM_END > > // return read byte from memory > return(g_val); > > #endif // SDCC > > } // read_byte > > > > >> Message: 2 >> Date: Tue, 16 Dec 2014 17:16:26 +0100 >> From: Philipp Klaus Krause <p...@spth.de> >> Subject: Re: [Sdcc-user] Migrating from Cosmic to SDCC; >> ASlink-Warning-Undefined Global (Philipp Klaus Krause) >> To: sdcc-user@lists.sourceforge.net >> Message-ID: <54905ada.9030...@spth.de> >> Content-Type: text/plain; charset="windows-1252" >> >> On 16.12.2014 16:35, Georg Icking-Konert wrote: >>> hi Philipp, hello Rolf, >>> >>> actually I have an STM8 application where I need access to >64kB >>> address >>> range. Specifically I want to program a 128kB device as a datalogger. >>> The SW already works under Cosmic (using @far identifier), but I >>> understand that sdcc doesn?t (yet?) support far address pointers. I >>> tried to work around this using inline assembler, see the below code. >>> Specifically sdcc aborts with the below error code in the line >>> containing the LDF instruction. Does this mean that even the assembler >>> doesn?t support far pointers? Or am I just using the wrong (i.e. >>> Cosmic) >>> syntax? For your support thanks a lot in advance! >> >> I'm not the one who wrote the assembler, but looking at the source it >> seems the .e needs to be outside the brackets. >> >> Philipp >> > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk_______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user