cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

New Contributor II

I am working on a Flash Write routine which is part of a boot loader for the CY8C27243.  I am using Application AN2100 as a starting point. I have all aspects of the bootloader working except for Flash Write.  After many days of debugging I have narrowed it down to the Supervisor ROM Flash Write sequence which uses the M8C SSC instruction. 

Here is a simplified sequence used to access a supervisor ROM routine as found in FLASHAPI.asm which is part of AN2100. This is part of the temperature table access routine and is a very simple use of the supervisor ROM and should work.

push A   ; save the State variable
push X
mov X, SP   ; copy SP into X
mov A, X     ; mov to A
add A, 3     ; create 3 byte stack frame
mov [0xF9], A   ; save stack frame for supervisory code
mov [0xF8], 0x3A   ; load the supervisory code for flash operations
mov A, 6    ; load A with FLASH_TEMP_TABLE_LOOKUP rom code
SSC          ; SSC call the supervisory code
pop X

Code execution does not return after the SSC instruction. I am assuming it is halting for some reason.

I have double checked all of the parameters and can't figure out what I am doing wrong.  Can SSC only be called when the M8C is in a certain mode ?  I have been able to read Flash successfully since that routine uses the absolute ROM read instruction ROMX which avoids an SCC. I wish there was such an easy way to do a write.

I have been working on this bootloader for nearly a month now and need to finish this before new product release.  

 

0 Likes
Reply
4 Replies
Moderator
Moderator

Kindly refer to PSoC1 Technical Reference Manual, Page 77, Section 3.1.2.6 TableRead function. Kindly check if all the parameters in Table 3-10 are valid for TableRead command. Usually in most cases, MVI Write page pointer may not be set to the correct value of 0.

Best regards,

Sampath Selvaraj

0 Likes
Reply
New Contributor II

Sampath,

Thank you for your reply. The part I am using is a CY827243 which only has 256 bytes of RAM in one page so the MVI Write page pointer is not used or accessible. I have read through the TRM many times, especially Section 3 which I think I have memorized by now. 

I have been able to get the Table Read and the Erase commands to run and return success however the Erase command does not actually erase Flash. When looking at Flash after the command completes, I see that the contents are unchanged. 

Are there any other issues that would prevent an SSC command from working ? Is there a requirement for stack location or other special systems register bits that need to be set a certain way ?

 

Thanks, Steve

 

0 Likes
Reply
New Contributor II

Will SSC commands only work after a power on reset ? I can not find any register bits in any of the system registers that apply to a one RAM bank part like the one I am using. I have stripped down the Erase command to the bare minimum hoping to figure out why it does not work. But find it returns success without erasing anything.

 

; State - Erase Block

push X
mov [0xF8], 0x3A   ; load the supervisory code for flash operations
mov X, SP                ;  copy SP into X
mov A, X                  ; mov to A
add A, 3                  ; create 3 byte stack frame
mov [0xF9], A      ; save stack frame for supervisory code
mov A, [X+bARG_BlockId]    ; get ERASE block ID
mov [0xFA], A    ; set block ID
mov A, [X+bDATA_PWErase]
mov [0xFC], A
mov [0xFE], 0x56    ; load the sequence delay count
mov A, 3                     ; load A with specific Flash operation
SSC                         ; SSC call the supervisory code
pop X

; Check the return code for success
cmp [bSSC_ResultCode], bSSC_SUCCESS
jz WriteBlock

0 Likes
Reply
New Contributor II

Is there an updated version of AN2100 that is available that may not have been published ?

After almost three weeks of solid frustration, I am at the point where I really doubt that the code in the AN2100 distribution zip file actually works. This has happened to me several times now when developing PSoC based products, the files on the web were old and don't work while apps engineers have updated versions that do work.

 

Or can you give me working versions of flash read/write code for the CY8C27xxx family that are proven to work ?

 

 

0 Likes
Reply