I would like to see an example (in MikroC) of how you transfer the next frame by using following format
[STX] [control code] [2 bytes control register] [8 bytes data] [BCC] [ETX]
My question is : what can I use from sendcodes to control the control register of the AD9833?
When the user programs the code “start frequency” then the PIC must control the DDS via the SPI
protocol for example.
I would like to have a start example, this is my interpretation:
if(UART_Data_ready() == 1)
{
byte_received = USART_Read()
and then I would like to split the frame [STX] then [CONTROL] and then those 5 bytes [BYTE4] [BYTE3] [BYTE2] [BYTE1] [BCC] [ETX]
Can somebody help me with an start example by example send the code from the laptop "START_FREQ" by example?
Kind regards
Code: Select all
#ifndef __UTILS_INCLUDED
#define __UTILS_INCLUDED
// ==========================================================================//
// Ascii codes for create BSC protocol //
// ==========================================================================//
#define STX 0x02 // 0000 0010
#define ETX 0x03 // 0000 0011
#define DLE 0x10 // 0001 0000
#define ACK 0x06 // 0000 0110
#define NAK 0x15 // 0001 0101
#define SYN 0x16 // 0001 0110
#define EOT 0x04 // 0000 0100
#define ENQ 0x05 // 0000 0101
// ==========================================================================//
// Control codes for BSC protocol //
// //
// We gebruiken het frame volgens het BSC protocol die is opgebouwd is: //
// [STX][1 BYTE CONTROL][DATA_BYTE_3][DATA_BYTE_2] _ //
// [DATA_BYTE_1][DATA_BYTE_0][BCC][ETX] //
// ==========================================================================//
// //
// Start Frequency //
// Stop Freqyency //
// Step //
// Reset //
// Waveform //
// Sleep //
// ==========================================================================//
#define RESET 0x00
#define START_FREQ 0x01
#define STOP_FREQ 0x02
#define SWEEP_FREQ 0x03
#endif
Thanks