/** @page can_example_2 CAN Example2: CAN peripheral example using interrupts
@par Example description
This example provides a short description of how to use the CAN peripheral.
Loop back mode is used for this testing purpose, so all transmitted messages
are received simultaneously. There is no need to control any external bus
connection or to communicate with other external units to run this example.
Main routine initials the process only and next all is going automaticaly on background.
TIM4 is used to control timing of the process. A message is sent and received in
regulary intervals repeatedly. The length and content of transmitted message stay
always constant (field MY_MESS). The ID of the message varies for each transmit-receive
cycle ordinary in 16 steps loop because an offset from 0 to 15 is added to defined ID
base (MY_MESS_STID). The flashing LEDs on evaluation board signal the bus communication:
LED1 ... a massage with no ID offset is transmitted
LED2 ... a message with offset from 1 to 15 is transmitted
LED3 ... not used
LED4 ... a message is received (passed the filters)
Optionally four different filter settings of incoming messages can be selected
in dependency on definition of symbols for filter and scale mode in configuration
section. Input filters can be switched between list and mask mode, filter scale
can vary between 8 and 16 bits.
When 8 bit scale and list mode are selected (ID_SCALE_8 and ID_LIST_MODE are
defined) only messages with offset form 0 to 7 are received. The rest from 8
to 15 are not received. That is why the bits STID0, STID1 and STID2 are masked
for 8 bits scale.
The same scale in masked mode (ID_MASK_MODE is defined) can receive all messages
because STID3 is masked in addition by predefined mask MY_MESS_STID_MASK, too.
At 16 bits scale (ID_SCALE_16 is defined) in list mode the message with no
offset can be received only. The rest 15 messages are not accepted.
The same scale in masked mode can receive 4 messages from 16 steps loop as the
STID3 and STID2 bits are masked, so any combination at these bits is accepted.
This example has been tested with ST Visual Develop (STVD) toolchain on STMS208 device
for both Cosmic and Raisonance compilers.
@par Directory contents
- main.c Main file containing the "main" function
- stm8s_it.c Interrupt vectors table
@par Hardware environment
STM8-EVAL evaluation board
@par How to use it ?
- Copy the directory content into RIDE or STVD workspace directory
- Open the workspace
- Rebuild all files
- Load the debug session
- Run program
- Watch the LEDs blinking
- When LEDs 2 and 4 flash together, transmitted message is accepted
- You can experiment with filter settings in init_CAN routine
Go to main file: CAN_example2\main.c
*/
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
没有合适的资源?快使用搜索试试~ 我知道了~
STM8各种硬件资源 例程
共70个文件
c:38个
txt:19个
stp:2个
5星 · 超过95%的资源 需积分: 50 56 下载量 183 浏览量
2012-04-08
02:00:04
上传
评论
收藏 314KB ZIP 举报
温馨提示
都是STM8S各硬件功能例程,包括ADC CLK TIME CAN UART WWDG....很不错的
资源推荐
资源详情
资源评论
收起资源包目录
stm8s_optimized_examples.zip (70个子文件)
Examples
TIM1_example4
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
LIN_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 10KB
TIM3_example2
stm8s_it.c 3KB
readme.txt 2KB
main.c 5KB
IWDG_example1
stm8s_it.c 3KB
readme.txt 1KB
main.c 4KB
CAN_example1
stm8s_it.c 3KB
readme.txt 3KB
main.c 7KB
UART3_example1
stm8s_it.c 3KB
readme.txt 1KB
main.c 4KB
TIM1_example3
stm8s_it.c 3KB
readme.txt 1KB
main.c 3KB
TIM4_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
TIM3_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
CLK_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
ADC2_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 7KB
TIM3_example3
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
CLK_example2
stm8s_it.c 3KB
readme.txt 2KB
main.c 5KB
CAN_example2
stm8s_it.c 3KB
readme.txt 3KB
main.c 8KB
TIM1_example1
stm8s_it.c 3KB
readme.txt 2KB
main.c 4KB
ADC2_example2
stm8s_it.c 3KB
readme.txt 2KB
main.c 5KB
WWDG_example1
stm8s_it.c 3KB
readme.txt 1KB
main.c 5KB
UART3_example2
stm8s_it.c 3KB
readme.txt 1KB
main.c 6KB
TIM1_example2
stm8s_it.c 3KB
readme.txt 1KB
main.c 4KB
STM8_Examples_V1.02.chm 223KB
Project
STVD&Raisonance
example.stw 203B
example.stp 14KB
STVD&Cosmic
example.stw 203B
example.stp 14KB
Include
stm8s.h 95KB
stm8s_type.h 3KB
RIDETest
example.rprj 272B
example.ctx 1KB
example.rapp 5KB
RIDE&Raisonance
example.rprj 272B
example.ctx 1KB
example.rapp 5KB
共 70 条
- 1
RDxhgd
- 粉丝: 2
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页