You are here

What is the correct C# code to this? | Cypress Semiconductor

What is the correct C# code to this?

Summary: 1 Reply, Latest post by HIMA on 01 Nov 2016 11:19 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Aegea Liang's picture
User
1 post

Hi,

I can program a hex file with a MiniProg3 and its GUI application as attached picture shows.

Then I followed the sample code in "C:\Program Files (x86)\Cypress\Programmer\Examples\Programming\PSoC3_5\SWD\C_Sharp", if I run this sample code directly without any changes, the prompt tells me:

"Failed! PSoC device is not acquired! Check connection of the chip to the programmer"

 

So I change the code with the settings on the GUI application, Below is the code of setting part in ProgramAll() function:

Mainly I have many issues on:

1. The prompt tells me "Failed! Device is not in ISSP mode"

2. CheckHexAndDeviceCompatibility() function could not pass.

3. EraseAll() function is unable to run.

4. Sometime I change the "Power" mode to "Power Cycle", sometimes I change the function from xxx() to PsoC3_xxx() if I found there is one, but it still could not work. Anyone know what's wrong there? Thanks!

 

 

Code:

 

if (pp == null) return -1;

string filePath = "E:/Projects/X2/CRTS-XRAY-XPS-Bootloader-v3.2.hex";

int hr;

//Port Initialization

//Setup Power - "5.0V" and internal

hr = pp.SetPowerVoltage("0.5", out m_sLastError);

if (!SUCCEEDED(hr)) return hr;

hr = pp.PowerOn(out m_sLastError);

if (!SUCCEEDED(hr)) return hr;

//Set protocol, connector and frequency

hr = pp.SetProtocol(enumInterfaces.SWD, out m_sLastError); //SWD-protocol

if (!SUCCEEDED(hr)) return hr;

hr = pp.SetProtocolConnector(0, out m_sLastError); //5-pin connector

if (!SUCCEEDED(hr)) return hr;

hr = pp.PSoC3_SetProtocolClock(enumFrequencies.FREQ_01_6, out m_sLastError); //3.0 MHz clock on SWD bus

// Set Hex File

int hexImageSize;

hr = pp.HEX_ReadFile(filePath, out hexImageSize, out m_sLastError);

if (!SUCCEEDED(hr)) return hr;

//Set Acquire Mode

pp.SetAcquireMode("Power", out m_sLastError);

//The "Programming Flow" proper

//Acquire Device

//hr = pp.DAP_Acquire(out m_sLastError);

hr = pp.DAP_Acquire(out m_sLastError);

if (!SUCCEEDED(hr)) return hr;

//Check Hex File and Device compatibility

//bool fCompatibility;

//hr = CheckHexAndDeviceCompatibility(out fCompatibility);

//if (!SUCCEEDED(hr)) return hr;

//if (!fCompatibility)

//{

// m_sLastError = "The Hex file does not match the acquired device, please connect the appropriate device";

// return -1;

//}

//Erase All

hr = pp.EraseAll(out m_sLastError);

if (!SUCCEEDED(hr)) return hr;

 

 

HIMA's picture
Cypress Employee
203 posts

Hello,

Are you powering the board externally or by miniprog3.?

Thanks,

Hima

Log in to post new comments.