Dear all, The Siemens Profibus Controller (SPC3), connected to a T89C51RD2 via P0 (multiplexed) and P2, has in its first few addresses registers/latches which I have to set in order to start using it. I believe the SPC to be wired to begin at 0x8000, as the output from P2.7 is inverted before being put into SPC3. In the options for target, I've set: memory model: small code rom: small off chip xdata memory: start: 0x8000 size: 0x600 The rest of the options are left blank. In STARTUP.A51 I've set: XDATASTART EQU 8000H XDATALEN EQU 600H and in code: AUXR = 0x0E; Suppose the address of the register that i'm trying to read is 04H in the SPC. Why does putchar(XBYTE[0x0004]) (or putchar(XBYTE[0x8004]) for that matter) not work? (ie. it outputs the value of the address, '04', and not its contents) I later used a for-loop to output XBYTE[0x0000] through to XBYTE[0xFFFF], which always seem to return the last 2 hex-digits of every address. I've also set the xdata in 'options for target' and Startup.A51 to 0x0000 with size 0x000 to the same effect. Did i miss out or misunderstand something? Any help would be greatly appreciated.
Jay, Yes, I understand how ALE is supposed to work. That's what is meant by multiplexing, right? I'm assuming that there's an address latch built into the SPC3, as it has an input-only ALE pin.The hardware description from Siemens unfortunately does not elaborate much on this. To my best understanding, this is how I think it should work: During the command putchar(XBYTE[0x0004]), P0 emits '04', P2 emits '00' ALE pulse latches the address, strobe RD, content from address 0x0004 in SPC3 is read and passed onto the UART. my actual code is of course not as simple as putchar(XBYTE[0x0004]), as I have to take into consideration that the output in hyperterminal is in ASCII. The main point is, the output I'm seeing on my hyperterminal is the address and not the content at this address. Why is that so? What did I miss out?
rather that XBYTE, couldn't you define some meaningfully-named variables using _at_? In either case, what does the generated assembler look like?
Hi Andrew, Below is the relevant part of the generated assembler code. Pls excuse and correct my bad programming. But in particular, I would like to find out why it didnt work. Thanks and much appreciated.
; for(aaa=0x0000; aaa<=0xFFFF; aaa++){ //addresses 0000h to FFFFh ; SOURCE LINE # 32 CLR A MOV aaa?040,A MOV aaa?040+01H,A ?C0003: ; bbb = ((XBYTE[aaa] >> 4) & 0x0F)+0x30; //higher 4 bits into ASCII 0-9 ; SOURCE LINE # 32 MOV DPL,aaa?040+01H MOV DPH,aaa?040 MOVX A,@DPTR SWAP A ANL A,#0FH ADD A,#030H MOV bbb?041,A ; if((bbb & 0x0F)>=0xA){ //ASCII A-F ; SOURCE LINE # 33 ANL A,#0FH CLR C SUBB A,#0AH JC ?C0006 ; bbb += 0x7; ; SOURCE LINE # 34 MOV A,#07H ADD A,bbb?041 MOV bbb?041,A ; } ; SOURCE LINE # 35 ?C0006: ; putchar(bbb); //outputs higher 4 bits in ASCII to hyperterminal ; SOURCE LINE # 36 MOV R7,bbb?041 ACALL _putchar