We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have a problem which I have fixed, but don't know what I have done has fixed it. As ever with these things there is a 99% chance that it is something stupid that I'm doing. The problem relates to a C165 processor linked to an SAE81C90 CAN chip (but I suspect that the expert will not need any CAN familiarity to follow this problem). In this can chip there are two 8 bit registers which the user must set individual bits high within to cause certain of 16 CAN messages to be transmitted. These registers can only be set (the CAN chip automatically unsets them when the message is successfully sent, alternatively, another pair of registers can be written to unset the transmit request bits). The registers are defined as:-
#define TransmitA (*((volatile unsigned char far*)0x200008)) #define TransmitB (*((volatile unsigned char far*)0x200009))
TransmitB|=0xff; TransmitA|=0xc0;
if ((TransmitA!=0)||(TransmitB!=0)) { //set lower LED red to indicate failed transmission LED2A = 0; LED2B = 1; fail=yes; } else { //sucessful transmission //set lower LED green to indicate successful transmission LED2A = 1; LED2B = 0; }
unsigned int temp_a; unsigned int temp_b;
TransmitB=0xff; TransmitA=0xc0;
temp_a=TransmitA; temp_b=TransmitB; if ((temp_a!=0)||(temp_b!=0)) { //set lower LED red to indicate failed transmission LED2A = 0; LED2B = 1; fail=yes; } else { //sucessful transmission //set lower LED green to indicate successful transmission LED2A = 1; LED2B = 0; }
The only difference I see is, that in version 2 you force that BOTH registers TransmitA AND TransmitB are read. If you use:
((TransmitA!=0)||(TransmitB!=0))
(TransmitA!=0)
(TransmitB!=0)
Hello, > If you use:
> ((TransmitA!=0)||(TransmitB!=0))
> (TransmitA!=0)
> (TransmitB!=0)
flag || printf("flag == false");