Hello
I am having problem with dsPIC V 5.4 and the CAN component.
I am compiling to a 30F6012A chip and are using the internal CAN controller.
In Flowcode I am setting the TX ID in a Macro. this works fine
Next Macro sets the TX Data
and finally a Macro Sends the Buffer.
When I look at the data that is sent. it seams that the SetTX ID and the Set TX Data can not co-exist and be carried out directly after eachother.
I can eithe set the TX ID value and using the data that is set at startup from the properties in the CAN component Properties that is red at boot.
Or I can Set th TX Data values if I am using the TX ID set in the component Properties. But I can not set both properties from inside the program.
The last macro is just ignored.
But there is a workaround. And that is if the TX ID property CAN Address Low is set to 0x00. The CAN Address High can ba any value. But this limits the number of usabale addresses to only 255 so it is
limiting what I would like to do with my program.
Any ideas how to fix this so I can set the CAN ID Lo value?
dsPIC CAN Component problem
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: dsPIC CAN Component problem
Hello,
I cannot see any reason in the code as to why this would be happening.
What values are you trying to pass into the ID low?
There is a logical shift of 3 bits to the right on the low ID so could this be the cause of the issue?
ID 1 would be high = 0 low = 8
ID 2 would be high = 0 low = 16
ID 3 would be high = 0 low = 24
I cannot see any reason in the code as to why this would be happening.
What values are you trying to pass into the ID low?
There is a logical shift of 3 bits to the right on the low ID so could this be the cause of the issue?
ID 1 would be high = 0 low = 8
ID 2 would be high = 0 low = 16
ID 3 would be high = 0 low = 24
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 94
- Joined: Wed Jul 29, 2009 5:15 pm
- Has thanked: 6 times
- Been thanked: 8 times
- Contact:
Re: dsPIC CAN Component problem
Hello Benj
to get it to work I have to enter digits like this:
CAN ID 1 = Hi =0 Low=32
CAN ID 2 = Hi =0 Low= 64
CAN ID 3 = Hi =0 Low= 96
CAN ID 4 = Hi=0 Low =128
CAN ID 5 = Hi =0 Low=160
CAN ID 6 = Hi =0 Low= 192
CAN ID 7 = Hi =0 Low= 224
CAN ID 8 = Hi=1 Low =0
My mistake was that I was entering Hi and Lo figures in Hex format. ei 0x32 etc. The adressing now works. Thanks.
to get it to work I have to enter digits like this:
CAN ID 1 = Hi =0 Low=32
CAN ID 2 = Hi =0 Low= 64
CAN ID 3 = Hi =0 Low= 96
CAN ID 4 = Hi=0 Low =128
CAN ID 5 = Hi =0 Low=160
CAN ID 6 = Hi =0 Low= 192
CAN ID 7 = Hi =0 Low= 224
CAN ID 8 = Hi=1 Low =0
My mistake was that I was entering Hi and Lo figures in Hex format. ei 0x32 etc. The adressing now works. Thanks.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: dsPIC CAN Component problem
If you want to convert an ID number into high and low bytes then it can be done like this.
ID = 1
ID_Low = ID << 3
ID_High = ID >> 5
ID = 1
ID_Low = ID << 3
ID_High = ID >> 5
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel