What is the correct C# code to this?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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;

0 Likes
1 Solution
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

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 ?

View solution in original post

0 Likes
11 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

   

Are you powering the board externally or by miniprog3.?

   

Thanks,

   

Hima

0 Likes
VaSe_1494681
Level 1
Level 1

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

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

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

0 Likes
lock attach
Attachments are accessible only for community members.
VaSe_1494681
Level 1
Level 1

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

   

 

   

   

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

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 ?

0 Likes
lock attach
Attachments are accessible only for community members.
VaSe_1494681
Level 1
Level 1

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

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Not PSoC3_5\SWD

   

Go to 

   

PSoC4\SWD\

VaSe_1494681
Level 1
Level 1

It is working! Thanks!

0 Likes
Anonymous
Not applicable

do you have C# example to communicate with usb? can you give me one? thank you very much

0 Likes
0 Likes

If you would like use SWD interface you can find some of c# examples into documents "PSoC Programmer COM User Guide" The place of this document is as usually is: "C:\Program Files (x86)\Cypress\Programmer\Documents" if the "PSoC Programer" software is installed on your PC

0 Likes