2003-07-30 06:41 PM
2003-07-27 09:11 PM
My customer face some problem with ST7 instruction while using inDart ST7FLite0. Please find below.
LD A, #$10 ; N flag = 0. This is correct. LD A, #$90 ; N = 1 ???? Why?? 90h is not negative value. LD A, #$0A0 ; load A0h into Accumulator A. CP A, #$30 ; N = 0. This is correct because A0h > 30h CP A, #$10 ; N = 1???? Why?? (A0h - 10h) > 0 And sub instruction show the same result as CP. And other question is about to start-up the FLITE09. For example, we connect LED to some I/O but every time when we power the application up by plug-in the supply voltage, the LED 1 time blink shortly and randomly. How could we eliminate this? Imagine as you connect the I/O with other peripheral and you need to check EMC testing. This blink MUST not occur. Cust also tried to config the I/O as push-pull and open-drain but it still blink. HELP!! Best regards, JOM2003-07-27 10:35 PM
What you are seeing is correct.
On datasheet you can find about the N flag: ''This bit is set and cleared by hardware. It is representative of the result sign of the last arithmetic, logical or data manipulation. It’s a copy of the result 7th bit. 0: The result of the last operation is positive or null. 1: The result of the last operation is negative (i.e. the most significant bit is a logic 1). Concerning the blinking LED, please set the DDR register as output before the initialization. [ This message was edited by: friul on 28-07-2003 11:10 ]2003-07-30 06:41 PM
In the first case i.e.
LD A, #$0A0 ; load A0h into Accumulator A. CP A, #$30 Here the result of subtraction of 0xA0 and 0x30 is 0x70 (0111 0000) bit 7 of the result is 0 so N flag is 0. In second case, the result of subtraction is (1001 0000) so the N flag is set to 1.