Camerart
Badges: 0
Rep:
?
#1
Report Thread starter 6 years ago
#1
Hi,

I am able to program PICs (not expertly) in PIC basic, but for technical reasons I need to be able to add some ASM (assembler) blocks into my programs. I've no experience with ASM.

Is there anyone who can help me with this please?

Camerart.
0
reply
elohssa
Badges: 3
Rep:
?
#2
Report 6 years ago
#2
What architecture? x86, x64 or other? Assembly is easy to learn (even x64) but it's only practical for a few select tasks (e.g. at work I'm often analyzing crash-dumps). With intrinsic code (in c/c++) where 'hidden' instructions can be directly accessed, one can argue assembly is not needed at all.
0
reply
Camerart
Badges: 0
Rep:
?
#3
Report Thread starter 6 years ago
#3
(Original post by elohssa)
What architecture? x86, x64 or other? Assembly is easy to learn (even x64) but it's only practical for a few select tasks (e.g. at work I'm often analyzing crash-dumps). With intrinsic code (in c/c++) where 'hidden' instructions can be directly accessed, one can argue assembly is not needed at all.
Hi Elohssa,

Thanks for your reply.

I am using a 18F2431 PIC which has special motor control attributes, and the program is written using a simulator (by Oshonsoft). This simulator doesn't support the special motor control attributes needed, so sections of the program need to be in Assembly. I can't understand c++.

Camerart.
0
reply
unprinted
Badges: 19
Rep:
?
#4
Report 6 years ago
#4
If it doesn't support them, does the hardware? Are you actually going to be controlling a motor? If not, have the simulated program just log what it would have done to a file / window / whatever.
0
reply
Camerart
Badges: 0
Rep:
?
#5
Report Thread starter 6 years ago
#5
(Original post by unprinted)
If it doesn't support them, does the hardware? Are you actually going to be controlling a motor? If not, have the simulated program just log what it would have done to a file / window / whatever.
The hardware in the 18F2431 is designed to control motors, and I intend to control a motor with it.
0
reply
unprinted
Badges: 19
Rep:
?
#6
Report 6 years ago
#6
(Original post by Camerart)
The hardware in the 18F2431 is designed to control motors, and I intend to control a motor with it.
Yes, I got that.

But you're developing the program on a simulator, rather than the real hardware, right?

So is the issue that you don't have a proper development kit that will generate the right code for the hardware, or that you want to test the program with the inadequate simulator?
0
reply
Camerart
Badges: 0
Rep:
?
#7
Report Thread starter 6 years ago
#7
(Original post by unprinted)
Yes, I got that.

But you're developing the program on a simulator, rather than the real hardware, right?

So is the issue that you don't have a proper development kit that will generate the right code for the hardware, or that you want to test the program with the inadequate simulator?
Sorry!!

I like the simulator and we are trying to get the administrator to work on this chip, and yes, I am trying to test the program with this simulator. I understand that it won't let me do that properly, so I will need to check it via a computer readout connected to the PIC itself once programmed with a mixture of Basic with ASM sections.

C
0
reply
unprinted
Badges: 19
Rep:
?
#8
Report 6 years ago
#8
While you're testing the program on the simulator, you just want to know what it's doing - that doesn't need any assembler, just PRINT statements (or whatever PIC BASIC has to show stuff).

For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.

Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
0
reply
Camerart
Badges: 0
Rep:
?
#9
Report Thread starter 6 years ago
#9
(Original post by unprinted)
While you're testing the program on the simulator, you just want to know what it's doing - that doesn't need any assembler, just PRINT statements (or whatever PIC BASIC has to show stuff).

For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.

Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
I can write the program on the simulator, then compile the ASM and HEX with it. I can't test it with the simulator, as it doesn't support the QUAD module, so I can only see results from the PIC once programmed and running, via a UART sending information of counters etc on a receiving computer.
I need to be able to add ASM for the QUAD and PWM into my basic program.
0
reply
CJKay
Badges: 19
Rep:
?
#10
Report 6 years ago
#10
(Original post by Camerart)
I can write the program on the simulator, then compile the ASM and HEX with it. I can't test it with the simulator, as it doesn't support the QUAD module, so I can only see results from the PIC once programmed and running, via a UART sending information of counters etc on a receiving computer.
I need to be able to add ASM for the QUAD and PWM into my basic program.
Look for the datasheet and go from there. PIC assembly is very simple, especially in comparison to other chips.
0
reply
Camerart
Badges: 0
Rep:
?
#11
Report Thread starter 6 years ago
#11
(Original post by CJKay)
Look for the datasheet and go from there. PIC assembly is very simple, especially in comparison to other chips.
Nice to know it's simple, but what is the simple process that will help me learn assembler? So far I've read the data sheet, which is long and has all the instructions, and I have printed out the ASM words, and some examples. When it comes to figuring out how write the code correctly. I'm lost.

Remember Eric Morecombe's quote? "I am playing all the correct notes, but not necessarily in the correct order"

C
0
reply
CJKay
Badges: 19
Rep:
?
#12
Report 6 years ago
#12
(Original post by Camerart)
Nice to know it's simple, but what is the simple process that will help me learn assembler? So far I've read the data sheet, which is long and has all the instructions, and I have printed out the ASM words, and some examples. When it comes to figuring out how write the code correctly. I'm lost.

Remember Eric Morecombe's quote? "I am playing all the correct notes, but not necessarily in the correct order"

C
You'll just have to Google some tutorials or something. If I remember how I learned it I'll get back to you, but that was a long time ago.
0
reply
Camerart
Badges: 0
Rep:
?
#13
Report Thread starter 6 years ago
#13
(Original post by CJKay)
You'll just have to Google some tutorials or something. If I remember how I learned it I'll get back to you, but that was a long time ago.
I've done a lot of googling, but I get the feeling that what I need to do (add ASM into an Oshonsoft basic program) isn't straight forward, and needs to be precise. C
0
reply
mfaxford
Badges: 1
Rep:
?
#14
Report 6 years ago
#14
Whilst I've not got any experience with PIC microcontrollers (I've mostly worked on ATMega chips) my understanding is a lot of the hardware interaction is from manipulating register values (bytes of memory to setup various features and read/write data).

Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).

You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
0
reply
Camerart
Badges: 0
Rep:
?
#15
Report Thread starter 6 years ago
#15
(Original post by mfaxford)
Whilst I've not got any experience with PIC microcontrollers (I've mostly worked on ATMega chips) my understanding is a lot of the hardware interaction is from manipulating register values (bytes of memory to setup various features and read/write data).

Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).

You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
In this thread I've been given a few alternatives, but I am limited to the OSHONSOFT simulator language PIC BASIC, and the PIC I'm working with is 18F2431. And I need to be able to add ASM into the basic program. This PIC is a motor control chip and has good internal firmware for what I am doing.

Not wishing to change the subject, but part of this project is to re-program an Orange radio https://www.hobbyking.com/hobbyking/..._Receiver.html which has an Atmega 328p chip controlling the RF22s radio module. If you would like to help with this please let me know. (Very valuable)

Any help with the above ASM would be very helpful. So far I've turned a LED on by touching another pin

Camerart.
0
reply
mfaxford
Badges: 1
Rep:
?
#16
Report 6 years ago
#16
(Original post by Camerart)
Not wishing to change the subject, but part of this project is to re-program an Orange radio https://www.hobbyking.com/hobbyking/..._Receiver.html which has an Atmega 328p chip controlling the RF22s radio module. If you would like to help with this please let me know. (Very valuable)
I've not personally done much with the RFM22B (although I do have a couple of play with) but I know lots of people that have used them (there's even been one on a cubesat). I've done a bit of work with the newer RFM69. One word of warning, if you want to stay legal check the allowed bands, power and duty cycle that can be used license free (I think you're limited to a small range of frequencies around 434MHz and 10mW for license free usage - IR2030 is likely the best starting place for that in the UK). I believe the RFM22 is end of Life now (although still available) so if this for a new project you might be better looking at something else.

I would also highly encourage using C and a native avr compiler rather than going down the arduino (based around C++) route for the 328p and also learn about interrupt routines as that can make the code much more efficient.

(Original post by Camerart)
Any help with the above ASM would be very helpful. So far I've turned a LED on by touching another pin
That sounds like a decent start, I'm afraid I can't help much as I've not worked with PICs and don't do much with ASM - although I'm sure there are forums around dedicated to the sort of thing you're doing.
0
reply
Camerart
Badges: 0
Rep:
?
#17
Report Thread starter 6 years ago
#17
(Original post by mfaxford)
I've not personally done much with the RFM22B (although I do have a couple of play with) but I know lots of people that have used them (there's even been one on a cube sat). I've done a bit of work with the newer RFM69. One word of warning, if you want to stay legal check the allowed bands, power and duty cycle that can be used license free (I think you're limited to a small range of frequencies around 434MHz and 10mW for license free usage - IR2030 is likely the best starting place for that in the UK). I believe the RFM22 is end of Life now (although still available) so if this for a new project you might be better looking at something else.

I would also highly encourage using C and a native avr compiler rather than going down the arduino (based around C++) route for the 328p and also learn about interrupt routines as that can make the code much more efficient.



That sounds like a decent start, I'm afraid I can't help much as I've not worked with PICs and don't do much with ASM - although I'm sure there are forums around dedicated to the sort of thing you're doing.
Please let me know about anything regarding the RFM22B as it is the one in the radio modules I have. If you are able to program later modules such as the RFM69 or similar, I'll also be interested, especially if they have an interface so I can use them. (I'm not natural at reading programs other than BASIC) I need to be able to send data and hopefully video (not high quality)

The UK frequencies are between 458.5 - 459.5 MHz.

I need to add some ASM sections into PICbasic any thing on 'comparing two numbers' and 'if this then that' would be very useful.

C.

Thanks.
0
reply
mfaxford
Badges: 1
Rep:
?
#18
Report 6 years ago
#18
(Original post by Camerart)
Please let me know about anything regarding the RFM22B as it is the one in the radio modules I have. If you are able to program later modules such as the RFM69 or similar, I'll also be interested, especially if they have an interface so I can use them. (I'm not natural at reading programs other than BASIC) I need to be able to send data and hopefully video (not high quality)

The UK frequencies are between 458.5 - 459.5 MHz.
The RFM22B datasheet suggests it only goes up to 453MHz, It may be configurable for higher but you'll be out of spec for the onboard filtering so there could be a significant impact on how well it works.

The RFM modules I've seen are generally all configured over SPI and you use that same interface to send it data to packetise and transmit. For any sort of video you're going to have to do a fair bit of processing so I'm not sure how feasible it is. It may help to know what sort of thing you're trying to achieve.
0
reply
Camerart
Badges: 0
Rep:
?
#19
Report Thread starter 6 years ago
#19
(Original post by mfaxford)
The RFM22B datasheet suggests it only goes up to 453MHz, It may be configurable for higher but you'll be out of spec for the onboard filtering so there could be a significant impact on how well it works.

The RFM modules I've seen are generally all configured over SPI and you use that same interface to send it data to packetise and transmit. For any sort of video you're going to have to do a fair bit of processing so I'm not sure how feasible it is. It may help to know what sort of thing you're trying to achieve.
Hi,

In an effort to lower the frequency of models for use in wooded areas, where higher frequencies get lost. I need different transmitter/receiver pairs with the lowest frequencies, for controlling the models while also receiving video of a quality for observation. While bearing in mind aerial length. Also frequencies not too close to one another.

So say 35Mhz for control and 459Mhz for data/video would be good.

I've looked at your suggestion of later models and a quick skim of the RFM69 data sheet and it seems a better idea to go with later models, than the RFM22B.

I think it might be better to start another 'Thread'. 'Programming radio modules' Does this sound ok?

C.
0
reply
elohssa
Badges: 3
Rep:
?
#20
Report 6 years ago
#20
(Original post by Camerart)
I need to add some ASM sections into PICbasic any thing on 'comparing two numbers' and 'if this then that' would be very useful.

C.

Thanks.
It depends on platform but generally conditional branching is achieved in ASM via either conditional moves (efficient but not use-able in many situations) or conditional jumps (unpredictable conditional jumps lead to heavy branch mispredictions). Control flow in ASM is a bit nasty. I think PIC-Basic has a GOTO instruction. Basically try writing all your control flow logic using only GOTO (no for/while loops etc) and you will know roughly what it's like.

Comparison in ASM is done via instructions that set flags e.g. in x86/x64 there is a CMP instruction that is exactly the same as the subtract (SUB) instruction except it doesn't modify the destination operand...

mov r1, 14
mov r2, 14
mov r3, 14

sub r1, r2 ;sets r1 to 0 and thus sets the ZERO flag
jz label ;jump to label if ZERO flag is set

;random code here

label:

cmp r2, r3 ;sets the ZERO flag but r2 is still 14 as CMP differs from sub and doesn't modify the destination

jz label ;create infinite loop
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

What factors affect your mental health the most right now?

Anxiousness about lockdown easing (194)
5.05%
Uncertainty around my education (560)
14.56%
Uncertainty around my future career prospects (430)
11.18%
Lack of purpose or motivation (530)
13.78%
Lack of support system (eg. teachers, counsellors, delays in care) (190)
4.94%
Impact of lockdown on physical health (232)
6.03%
Loneliness (323)
8.4%
Financial worries (141)
3.67%
Concern about myself or my loves ones getting/having been ill (151)
3.93%
Exposure to negative news/social media (172)
4.47%
Lack of real life entertainment (218)
5.67%
Lack of confidence in making big life decisions (343)
8.92%
Worry about missed opportunities during the pandemic (361)
9.39%

Watched Threads

View All