
function [err] = BK_SetCCMode(sp)

PACKET_LENGTH = 26;
LoadCmdPacket = zeros(1,PACKET_LENGTH);
LoadCmdPacket(1:4)  = [ hex2dec('aa') 00 hex2dec('28') 00];
LoadCmdPacket(end) = rem(sum(LoadCmdPacket(1:end-1)),256);  % Compute checksum
fwrite(sp,LoadCmdPacket);

A = fread(sp,PACKET_LENGTH);

% Validate response length first
if numel(A) < 4
    err = 1; % short/invalid response
    return
end

% Check response byte
if A(4) == hex2dec('80')
    err = 0; % success
else
    err = 1; % device returned failure code
end
end

