In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zamuel_a wrote: Here is the code but it might be alittle confusing. There are alot's of "dummy" nops in some routines that I put in to prevent the "read modify write" problem, but it didn't make any difference The loop works ok upto about 230, above that and it's very unstable and if I run it for about 250 loops it never works. The loop should go on for 65536 loops and it worked then I forced the resetpin high ;-------------------------- DEVICE DIRECTIVES -------------------------- DEVICE SX28,OSCHS3,TURBO IFDEF __SASM ;SASM Directives DEVICE STACKX,OPTIONX IRC_CAL IRC_SLOW ELSE ;Parallax Assembler Directives DEVICE STACKX_OPTIONX ENDIF RESET initialize ;---------------------------- DEBUG SETTINGS --------------------------- FREQ 4_000_000 ;------------------------------ VARIABLES ------------------------------ data_low EQU $08 data_high EQU $09 temp EQU $0E ORG $000 ;------------------------ INITIALIZATION ROUTINE ----------------------- WE EQU RA.3 OE EQU RA.2 BUSY EQU RA.1 ADDR_EN EQU RA.0 A0A7 EQU RB A8A15 EQU RC D0D7 EQU RB D8D15 EQU RC ;Port signals SX_LOAD_ADDR_EN MACRO setb ADDR_EN ENDM SX_LOAD_ADDR_DI MACRO clrb ADDR_EN ENDM SX_OE_HIGH MACRO setb OE ENDM SX_OE_LOW MACRO clrb OE ENDM SX_WE_HIGH MACRO setb WE ENDM SX_WE_LOW MACRO clrb WE ENDM ;Set RAM address A0-A15 SETADDR MACRO ADDRH ADDRL nop nop mov !A0A7,#$00 ;Port B all outputs, LOW nop nop mov !A8A15,#$00 ;Port C all outputs, HIGH nop nop mov A0A7,ADDRL nop nop mov A8A15,ADDRH nop nop SX_LOAD_ADDR_EN nop nop nop nop nop SX_LOAD_ADDR_DI nop nop ENDM ;Read data from D0-D15 to DESTH and DESTL READ_DATA MACRO DESTH,DESTL mov !A0A7,#$FF ;Port B all inputs, LOW mov !A8A15,#$FF ;Port C all inputs, HIGH nop nop nop SX_OE_LOW ;Read data nop ;1 nop räcker? nop nop nop mov DESTL,D0D7 mov DESTH,D8D15 SX_OE_HIGH ENDM ;Add a 16 bit value with a 8 bit value ADD16_8 MACRO ARG1,ARG2 add ARG1,ARG2 snc inc ARG1 + 1 ENDM ;------------------------ INITIALIZATION ROUTINE ----------------------- initialize mode $0F ;Set Mode to allow Direction configuration ;---------------------------- MAIN PROGRAM ----------------------------- main clrb RA.1 ;Enable BUSY signal mov !RA,#%0000 ;Port A all outputs mov RA,#%1100 ;No WE or OE to RAM yet mov temp,#0 mov temp+1,#0 loop SETADDR temp+1,temp READ_DATA data_high,data_low ADD16_8 temp,#1 cjbe temp+1,#$FF,loop ; cjbe temp,#230,loop loop2 jmp loop2 END ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=400054#m400071 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)