Thank you both for your time and answers.
I think I found a solution, not sure why is this happening but works...
I tread the numbers I read from radio as BCD, I convert them to binary, increase the volume by adding 10, convert them to BCD again and finally send them to the radio.
I'm sure there must be an easier way to do this, because I can send other settings very easy.
The civa is just a constant (address of the radio) and is civa = $70, the same as CIVA = $70.
Here is the working code for your information, maybe you can help me to make it simpler without all these calculations.
Thanx againCode:VOLUP1: ' '-------------------------------------------------------------------------------------------------------------------------------- ' Volume in range 000 - 254 ' f1 values are 00,01,02 ' f2 values are 00 - 99 '-------------------------------------------------------------------------------------------------------------------------------- SEROUT2 CIVP,CIVS,[$FE,$FE,CIVA,$E0,$14,$01,$FD] ' Send this to the radio to read Audio SETTING - WORKS !!! SERIN2 CIVP,CIVS,[SKIP 6,f1,f2] ' Skip first 6 useless bytes and read next 2 volume bytes - WORKS !!! '-------------------------------------------------------------------------------------------------------------------------------- ' The next 4 lines are only for testing and to display a total volume value (000-254) to LCD in decimal '-------------------------------------------------------------------------------------------------------------------------------- x1 = f1 & 001111 ' read units - WORKS !!! x2 = f2 >> 4 ' divide / 2^4 = 16 (tens) - WORKS !!! x3 = f2 & 001111 ' read units - WORKS !!! Z = x1 * 100 + x2 * 10 + x3 ' a number between 0 - 254 '-------------------------------------------------------------------------------------------------------------------------------- f3 = ((f1 >> 4) * 10) + (f1 & $0f) ' Convert BCD to binary f4 = ((f2 >> 4) * 10) + (f2 & $0f) ' Convert BCD to binary f4 = f4 + 10 ' Increase volume by 10 units - This is what I want to do IF f4 > 99 THEN f4 = 0 ' Make sure result is less than 100 f3 = f3 + 1 ENDIF IF f3 > 1 AND f4 > 54 THEN ' If volume > 254 go back to volume 0 f3 = 0 f4 = 0 ENDIF f5 = ((f3 / 10) << 4) + (f3 // 10) ' Convert bin to BCD f6 = ((f4 / 10) << 4) + (f4 // 10) ' Convert bin to BCD pause 50 ' Give some time to radio to recover from SERIN2 SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,f5,f6,$FD] ' Send this to the radio for NEW VOLUME setting - THIS WORKS NOW :) pause 50 ' Give some time to radio to recover from SEROUT2 RETURN '--------------------------------------------------------------------------------------------------------------------------------
Fanias




Bookmarks