Code:Hi, I understand that with the PIC16F648 you control the configuration of the 7 Control channels of a radio control (R/C). For each of the 7 control channels you have the following parameters: - Servo Reversing (1 byte) - Variable Dual Rate (3 bytes) - Adjustable Travel Volume (3 bytes) These parameters are stored in the EEPROM of the PIC. For each control channel you use 7 bytes of EEPROM. In total 49 bytes are used in the EEPROM. Store the values in the EEPROM as data blocks. Each block of data will contain the 7 bytes necessary to store the parameters of a channel. We will call these data blocks RECORDS. Below you can see the map of your EEPROM. The first 7 bytes (0-6) of the EEPROM are not used and are available for other uses. * * * EEPROM map Where: X= Not used R= Servo Reversing (1 byte) DDD= Dual Rates (3 bytes) TTT= Travel Volume (3 bytes) REC 0 REC 1 REC 2 REC 3 REC 4 REC 5 REC 6 REC 7 DUMMY (CH1) (CH2) (CH3) (CH4) (CH5) (CH6) (CH7) _______-------_______-------_______-------_______------- XXXXXXXrdddtttRDDDTTTrdddtttRDDDTTTrdddtttRDDDTTTrdddttt 01234567891111111111222222222233333333334444444444555555 (EE Address) 0123456789012345678901234567890123456789012345 To find out the record address for the selected channel: (You know the channel number because you have selected it on the LCD). record_address = channel_number * 7 Once you have calculated the record address: (The address of the first byte of the record). ------------------------------------------ To read the Servo Reversing byte from the EEPROM: READ record_address, servo_reversing ------------------------------------------ To read the Dual Rate first byte from the EEPROM: READ record_address + 1, dual_rate_b1 To read the Dual Rate second byte from the EEPROM: READ record_address + 2, dual_rate_b2 To read the Dual Rate third byte from the EEPROM: READ record_address + 3, dual_rate_b3 ------------------------------------------ To read the Travel Volume first byte from the EEPROM: READ record_address + 4, travel_volume_b1 To read the Travel Volume second byte from the EEPROM: READ record_address + 5, travel_volume_b2 To read the Travel Volume third byte from the EEPROM: READ record_address + 6, travel_volume_b3 ------------------------------------------ Below are the variables in RAM. These variables are used as temporary storage and their content will change based on the selected channel number. channel_number record_address servo_reversing dual_rate_b1 dual_rate_b2 dual_rate_b3 travel_volume_b1 travel_volume_b2 travel_volume_b3 Do the same to WRITE to the EEPROM. Best regards, Luciano
Bookmarks