ASSEMBLY LANGUAGE ON PSOC

Questions about programming (not codeing) PSoCs and Encore II as well as freeware programming hardware and software are discussed here. This is also the place to talk about production programming. Programming means loading a HEX file in to the Flash, not, writing your program.

Moderator: ericb

ASSEMBLY LANGUAGE ON PSOC

Postby yinkirsi » Mon Dec 03, 2007 3:45 pm

We are currently trying out the PSOC but we've encountered a problem. We already have the assembly code but we can't figure out how the input and output works on PSOC using the assembly language. Please reply asap! thanks :D
yinkirsi
Newbie
Newbie
 
Posts: 3
Joined: Mon Dec 03, 2007 3:39 pm

Postby graaja » Wed Dec 05, 2007 3:11 am

You can use the PRTxDR register to write or read to pins.

For example, if you want to read from Port2:

Code: Select all
mov A, reg[PRT2DR]


To set P0.0

Code: Select all
or reg[PRT0DR], 0x01


To clear P0.0

Code: Select all
and reg[PRT0DR], ~0x01
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Website: http://www.planetpsoc.com
Location: India

Postby mrzee » Thu Dec 06, 2007 9:18 pm

Just be careful when using RMW instructions on the PSoC as it ports are not buffered.
It's far better to use a shadow register as an intermediate.
MrZee
User avatar
mrzee
The Big Cheese
The Big Cheese
 
Posts: 384
Joined: Mon Jan 05, 2004 5:59 pm
Location: Virginia, USA

Re: ASSEMBLY LANGUAGE ON PSOC

Postby Sinthana » Sun Oct 07, 2012 12:12 am

hi.. i am new to psoc.. i hav d following assembly code for temerature sensing.. can anyone please explain it step by step n help me with blocks interconnection.. i need to modify it for presure sensing..

// PSoCEval1 Connections:
// port0_pin1 -> VR = ADC Input (0-Vdd)
// port1_pin6 -> RX = serial RX
// port2_pin7 -> TX = serial TX
//
//-----------------------------------------------------------------------------


include "m8c.inc" // include m8c specific declarations
include "psocapi.inc" // include User Module API specific declarations

export _main:

area bss(RAM) // inform assembler that variables follow
iResult: blk 2 // ADC result variable
area text(ROM,REL) // inform assembler that program code follows


_main:
mov A, UART_PARITY_NONE
lcall UART_1_Start // Enable UART

mov A, >sRomString1
mov X, <sRomString1
lcall UART_1_CPutString // Display example string
lcall UART_1_PutCRLF

mov A, PGA_1_MEDPOWER
lcall PGA_1_Start // Turn on PGA power
mov A, ADCINC12_1_MEDPOWER
lcall ADCINC12_1_Start // Turn on ADC power
mov A, 0
lcall ADCINC12_1_GetSamples // Sample forever

lcall LCD_1_Start // Init the LCD
mov A, 0 // row
mov X, 0 // column
lcall LCD_1_Position
mov A, >sRomString2
mov X, <sRomString2
lcall LCD_1_PrCString // Display string

M8C_EnableGInt // Enable Global interrupts

loop:
lcall ADCINC12_1_fIsDataAvailable // If conversion complete....
jz loop

lcall ADCINC12_1_iGetData // Get result, convert to unsigned and clear flag
mov [iResult+1], A
mov [iResult+0], X
add [iResult+0], 0x08 // add 0x0800 to result
cmp A,0x3A
jnz L1
mov A,0x01
lcall LED_1_Switch
L1:
cmp A,0x3E
jnz L2
mov A,0x00
lcall LED_1_Switch
L2:lcall ADCINC12_1_ClearFlag

mov A, [iResult+1]
mov X, [iResult+0]


mov A, 1 // row
mov X, 0 // column
lcall LCD_1_Position // display result in hex
mov A, [iResult+1]
mov X, [iResult+0]
lcall LCD_1_PrHexInt

jmp loop


area lit

sRomString1:
DS "Example ADC_UART_LCD"
db 00h

sRomString2:
DS "PSoC LCD"
db 00h

area text
Sinthana
Newbie
Newbie
 
Posts: 3
Joined: Thu Sep 27, 2012 8:13 pm

Re: ASSEMBLY LANGUAGE ON PSOC

Postby bobmarlowe » Sun Oct 07, 2012 1:14 am

It is always advisable to start a new thread in the right sub-forum instead of using a thread that was started 5 years ago.
As a newbee, which we all have been like you, I would strongly recomend you to program in C and not in assembly.
C is (at least a bit) more descriptive than asm, the compiler is free (needs registration) and the generated overhead is reasonable and to understand and use PSoC1 any help will bring you further.
As I can see from the code the function of the PSoC is straight forward:
After Initializing the used components (ADC, LCD, UART) the program waits for an ADC-conversion ready, calculates temp from it, displays it on the LCD and transmits it via the UART.
It looks a bit as if this is made for a 3270 PSoC1 development kit, do you have got one?
The program is probably from an application note and normally there is a project written in C for a similar application. The basics are usually the same and the differences are a bit of math to calculate and/or adjust the output to the physical properties.
Have a look here or here.

Happy coding
Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany


Return to “%s” Device Programmers

Who is online

Users browsing this forum: No registered users and 1 guest