You are here

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

What is the correct C# code to this?

Summary: 8 Replies, Latest post by Vasily Semichev on 28 Dec 2016 07:35 AM PST
Verified Answers: 2
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
369 posts

Hello,

Are you powering the board externally or by miniprog3.?

Thanks,

Hima

vasilyvs_1494681's picture
User
6 posts

Hello,

I am working with MiniProg 3 and with CY8CKIT_059 PSoC 5L Kit Prog. Al devices are good working with "PSOC Pogramrmer". I would like to study C# examples from C:\Program Files (x86)\Cypress\Programmer\Examples\Programming\PSoC3_5\SWD\C_Sharp but I have got some of error messages. I placed into "HEX-file" folder "Design12.hex" file - the same file I used for successfully programming using  "PSOC Pogramrmer". First message is "The hex file does not match to acquired device.....". If I tried to avoid this point using debugger, the next message is "This PSoC device doesen't support PSOC3_EraseAll() API". I have got the same results in both devices - MiniProg 3 and with CY8CKIT_059 PSoC 5L Kit Prog. I am novice at C# and COM and I would be glad of any advices for solving of my problems

 

embedded.engg21_2218296's picture
User
27 posts

Hi, can you read the device ID so that we can confirm why it mismatched with hex file ?

vasilyvs_1494681's picture
User
6 posts

Hi, thanks for the reply!

chipGtagID = 11,177,20,119

hexJtagID = 4,38,17,147

The device is CY8C4125AZI-483, the hex-file I made using PSoC Creator 3.3.

I attached some screenshots from VS debugger anf hex file I am using

 

Attachments: 
embedded.engg21_2218296's picture
User
27 posts

Since, you are trying to program CY8C4125AZI-483, which is PSoC4 device, you are supposed to use C# example provided in folder ..\Cypress\Programmer\Examples\Programming\PSoC4\SWD\C_Sharp\C_Sharp. Are you using the correct C# example ?

vasilyvs_1494681's picture
User
6 posts

Yes, I am using this VS project on C_Sharp from C:\Program Files (x86)\Cypress\Programmer\Examples\Programming\PSoC3_5\SWD

Attachments: 
embedded.engg21_2218296's picture
User
27 posts

Not PSoC3_5\SWD

Go to 

PSoC4\SWD\

vasilyvs_1494681's picture
User
6 posts

It is working! Thanks!

Log in to post new comments.